27.08.2015 Views

Advanced Bash−Scripting Guide

Advanced Bash-Scripting Guide - Nicku.org

Advanced Bash-Scripting Guide - Nicku.org

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Advanced</strong> <strong>Bash−Scripting</strong> <strong>Guide</strong><br />

bash$ echo −e x\ty<br />

xty<br />

bash$ echo −e "x\ty"<br />

x y<br />

(Thank you, Wayne Pollock, for pointing this out.)<br />

[15] "Word splitting", in this context, means dividing a character string into a number of separate and<br />

discrete arguments.<br />

[16] Be aware that suid binaries may open security holes and that the suid flag has no effect on shell scripts.<br />

[17] On modern UNIX systems, the sticky bit is no longer used for files, only on directories.<br />

[18] As S.C. points out, in a compound test, even quoting the string variable might not suffice. [ −n<br />

"$string" −o "$a" = "$b" ] may cause an error with some versions of Bash if $string is<br />

empty. The safe way is to append an extra character to possibly empty variables, [ "x$string" !=<br />

x −o "x$a" = "x$b" ] (the "x's" cancel out).<br />

[19] The pid of the currently running script is $$, of course.<br />

[20] The words "argument" and "parameter" are often used interchangeably. In the context of this document,<br />

they have the same precise meaning, that of a variable passed to a script or function.<br />

[21] This applies to either command line arguments or parameters passed to a function.<br />

[22] If $parameter is null in a non−interactive script, it will terminate with a 127 exit status (the Bash error<br />

code code for "command not found").<br />

[23] These are shell builtins, whereas other loop commands, such as while and case, are keywords.<br />

[24] An exception to this is the time command, listed in the official Bash documentation as a keyword.<br />

[25] A option is an argument that acts as a flag, switching script behaviors on or off. The argument<br />

associated with a particular option indicates the behavior that the option (flag) switches on or off.<br />

[26] The C source for a number of loadable builtins is typically found in the<br />

/usr/share/doc/bash−?.??/functions directory.<br />

Note that the −f option to enable is not portable to all systems.<br />

[27] The same effect as autoload can be achieved with typeset −fu.<br />

[28] These are files whose names begin with a dot, such as ~/.Xdefaults. Such filenames do not show<br />

up in a normal ls listing, and they cannot be deleted by an accidental rm −rf *. Dotfiles are generally<br />

used as setup and configuration files in a user's home directory.<br />

[29] This is only true of the GNU version of tr, not the generic version often found on commercial UNIX<br />

systems.<br />

[30] A tar czvf archive_name.tar.gz * will include dotfiles in directories below the current working<br />

directory. This is an undocumented GNU tar "feature".<br />

[31] This is a symmetric block cipher, used to encrypt files on a single system or local network, as opposed<br />

to the "public key" cipher class, of which pgp is a well−known example.<br />

[32]<br />

A daemon is a background process not attached to a terminal session. Daemons perform designated<br />

services either at specified times or explicitly triggered by certain events.<br />

The word "daemon" means ghost in Greek, and there is certainly something mysterious, almost<br />

supernatural, about the way UNIX daemons silently wander about behind the scenes, carrying out their<br />

appointed tasks.<br />

Appendix J. Copyright 442

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!