README

Fileset is a mini-DSL to ease creation, manipulation and inspection offilesystem hierarchies, including content of files. It can express arbitrarystrings both as filenames and file content, with only very simple escaping fornewlines. It can be easily generated using a templating/macro language.

Fileset language consists of statements. Each line that starts with non-tabcharacter is start of new statement. Lines that start with tab character arecontinuation lines from previous statement, where the newline is semanticallyretained but the tab character is ignored where processing. This means that youcan embed literal "\n" by replacing each occurence with "\n\t", which is stillconveniently readable in plain text, unlike most other escaping schemes.

Each statement with single command character. The command may either take fixednumber of tab-separated argument or operate on whole rest of statement.When the command does not consume whole statement, next command is taken from thefirst character after a tab delimiting the last argument.Two special commands ("/" and "P") do nothing by themselves, they only set thepath (filename) for subsequent commands to operate on.

Commands that take one argument:

/<path> set the path (filename) to operate on (may not contain tab, see P)

c<flags><tab><content> create plain file with specified content (content may not contain tab, see C) a leading newline is appended if the content does not end in newline, unless following flags are given: "n" - always append a newline "N" - never append a newline

X<flags><tab><content> create regular file with content specified as hexdump as produced by xxd

!<flags><tab><command> run shell command on file, depending on the flags: "i" - redirect stdin from the file for the command "o" - redirect stdout to the file for the command, rewriting it "a" - redirect stdout to the file for the command, appending to it "f" - use command as a filter, redirecting the file to stdin and stdout to temporary file, overwriting the original if change was detected also takes additional flags as for "f" command "c" - with "f" create empty file first if it doesn't exist yet

Flags taken by the rfdlhcLHC commands: "!" - remove existing file if already present and of different type (eg. symlink instead of directory) files of same type are always replaced even without this flag "r" - when removing existing file (directory), do it recursively (rm -r) "f" - when removing existing file, do it forcibly (rm -f) "p" - create parent directories if they don't exist (mkdir -p)

?<flags><tab><command> TODO flags: "i" - redirect stdin from the file for the command

fsapply [-x] root [file [file ...]] Convert fileset language to shell script and execute it, relative to root directory. The shell executed is determined by FILESET_SHELL environment variable, defaulting to "sh". The -x option is passed to the shell, so tracing can be turned on.

fslist [file [file ...]] Print out attributes and content of given files in fileset format. If directories are given, they are processed recursively. When nothing is given, current working directory is used.