# nobodd.sh

This module contains the implementation (and entry point) of the nobodd-sh application.

## Application functions

nobodd.sh.main(args=None)

  The main entry point for the nobodd-sh application. Takes args, the sequence of command line arguments to parse. Returns the exit code of the application (0 for a normal exit, non-zero for an error).

  If `DEBUG=1` is found in the application’s environment, top-level exceptions will be printed with a full back-trace. `DEBUG=2` will launch PDB in post-mortem mode.

nobodd.sh.get_parser()

  Returns the command line parser for the application, pre-configured with defaults from the application’s configuration file(s). See `ConfigArgumentParser()` for more information.

nobodd.sh.get_paths(inputs, outputs, *, allow_std=False)

  Given inputs and outputs, two iterables of filenames (or paths), which may include image prefixes (e.g. `test.img:1/filename`), returns a `dict` mapping each filename to a `Path` or `FatPath` instance.

nobodd.sh.same_fs(path1, path2)

  Test whether path1 and path2 (both either `Path` or `FatPath` instances) are part of the same file-system.

  Note that this does not mean part of the same mount in the Linux file-system. This returns `True` if both paths are `Path` instances, or if both paths are `FatPath` instances and both belong to the same `FatFileSystem` instance.

## Command implementations

nobodd.sh.do_cat(config)

  Concatenate content from the given files, writing it to stdout by default. If - is given as a filename, or if no filenames are specified, stdin is read. In order to permit output to a file within an image, -o is provided to specify an output other than stdout.

nobodd.sh.do_cp(config)

  Copy the specified file over the target file, if only one source is given, or copy the specified files and directories into the target directory, if the target is a directory.

nobodd.sh.do_help(config)

  With no arguments, displays a list of %(prog)s commands. If a command name is given, displays the description and options for the named command.

nobodd.sh.do_ls(config)

  List information about the files, or the contents of the directories given. Entries will be sorted alphabetically, unless another ordering is explicitly specified. By default, hidden files (beginning with “.”) are excluded from the output, unless -a is provided.

nobodd.sh.do_mkdir(config)

  Creates the directories specified, which must not exist either as directories or regular files.

nobodd.sh.do_mv(config)

  Move the specified file over the target file, if only one source is given, or move the specified files and directories into the target directory, if the target is a directory.

nobodd.sh.do_rm(config)

  Removes the files specified. If -r is given, will recursively remove directories and their contents as well.

nobodd.sh.do_rmdir(config)

  Removes the directories specified, which must be empty.

nobodd.sh.do_touch(config)

  Update last modified timestamps, creating any files that do not already exist.

## Support classes

class nobodd.sh.StdPath(for_write)

  A rudimentary path-like object representing stdin / stdout. Only supports the `name` property, and the `open()` and `unlink()` methods.

  open(mode)

    Returns the standard stream represented by the path.

  unlink()

    Raises an error if an attempt is made to remove a standard stream.

  property name

    Returns the name of the standard stream this path represents.