The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

snag - reserve or find version-aware file and directory names

SYNOPSIS

snag [-fvh] name[/] ...
snag [-fvh] [--lshigh | --lslow | --next] name[/] ...

DESCRIPTION

The snag command creates node name as a file, or as a directory if name ends with a '/' character. It outputs the created node name on success and exits with status 0. Unlike the touch(1) command, snag will normally fail if the node exists (exit status 1) before it tries to create it. Other errors result in exit status 2 and a message on stderr. If -f (force) is given, an attempt will be made first to remove a pre-existing node.

In the presence of --lshigh, --lslow, or --next, the node name is considered a base for numbered version names that end in digits. In this case, any terminal digits in name ("1" by default if there are no terminal digits) are interpreted specially.

If --lshigh ("list high")is given, no node will be created, but the highest existing numbered version will be returned, where candidate versions will be any node name beginning with base name and ending in any string of digits. Similarly for --lslow ("list low"), but for the lowest existing numbered version.

If --next is given, an attempt will be made to create the next highest numbered version. If a race condition is detected, several attempts will be made. The next highest version is determined by first finding the highest current version number and adding 1 to it. It is an error if the type of the requested version (file or directory) is different from that of the current high version unless --force is given.

EXAMPLES

  $ snag v4/
  v4/
  $ echo `for i in a b c; do snag --next v001/; done`
  v005/ v006/ v007/
  $ snag --lshigh v2
  v007/
  $ snag foo
  foo
  $ snag --next foo.; snag --next foo.
  foo.1
  foo.2

OPTIONS

-h, --help

Print extended help documentation.

--man

Print full documentation.

--version

Print the current version number and exit.

SEE ALSO

touch(1)

AUTHOR

John Kunze jak at ucop dot edu

COPYRIGHT

  Copyright 2009 UC Regents.  Open source Apache License, Version 2.