Menu

Design choices

Paul Gover

Design choices

  1. POSIX script, not BASH or other extensions. Because POSIX is already hard enough to keep secure, as DASH outperforms BASH, and as Busybox's shell is POSIX, doall will work there.

  2. Overuse '*' as the wildcard replacement marker, rather than the Windows and 'rename' command's use of '=', as in:
    mv *.jpg =.jpeg
    Simply because it (a) allows reuse of the pattern parsing code, and (b) it means '=' is not made into a new special character.

  3. Don't allow multiple statements in the command argument. Actually, this isn't so much a design choice as a side-effect of quoting every word in the command string generated.

  4. Use options common to shell "set" (such as -i, -x) and have synonyms as common commands (such as -v).

  5. Very simple option processing, short form only. That's 'cos getopts is a DASH built-in, and anything else would require yet more code.

  6. Don't "quote" filenames in the '-p' pretend mode listing. While BASH allows "printf '%q'" to convert special characters to escape sequences, it's not POSIX.
    GNU 'printf' supports '%q', but we can't be sure it's available. More to the point, as pretend mode colours the inserts using ANSI sequences, so %q will also escape the ANSI sequence and the colours vanish!

  7. No '-a' ("Ask" mode). An early version did have '-a', that used pretend mode, and then reran everything from scratch. That allows for races where a file gets deleted. Curing that would need a potentially large temporary store of filenames to process, and that's hard due to quoting issues as above. Instead, the '-i' interactive mode is equivalent and safe.

  8. Shortest-last parsing. Globbing wildcards can easily produce ambiguous parses:
    aa.bb.cc-ee.ff-gg.hh parsed with '*-*.*'
    could match as either:
    aa.bb.cc - ee . ff-gg.hh
    aa.bb.cc-ee.ff - gg . hh
    Shortest-last parsing means that in general filename extensions get treated as expected:
    vmlinuz.old.efi parsed with '.'
    is matched as
    vmlinuz.old . efi
    which is probably what is normally wanted.


Related

Wiki: Home

MongoDB Logo MongoDB