[pocket-linux] some discrepancies in 6.3.4, 6.3.5?
David Horton
dhorton at speakeasy.net
Sat Feb 12 08:44:18 CST 2005
rainer wrote:
> hello,
>
> tried to send this problem on thursday from pine but it hasn't seemed
> to have arrived, please excuse the repeat if it does!
>
> i was continuing with ch. 6 when i noticed a few possible
> discrepancies (?);
>
> in 6.3.4 for the init.d/rc script we have,
>
> # Execute the kill scripts first.
> for SCRIPT in $SCRIPT_DIR/K*; do
> if [ -x "$SCRIPT" ]; then
> $SCRIPT stop;
> fi;
> done;
> #
> # Do the Start scripts last.
> for SCRIPT in $SCRIPT_DIR/S*; do
> if [ -x $SCRIPT ]; then
> $SCRIPT start;
> fi;
> done;
>
> inside the square brackets we have "$SCRIPT" in kill and $SCRIPT in
> start.
> is this intentional?
>
> in 6.3.5 in the modified local_fs script we have,
>
>
> start)
> echo "Checking local filesystem integrity."
> fsck -ATCp
> if [ $(($?)) -gt $((1)) ]; then
>
> but the original local_fs from 5.3.7 has
>
>
> fsck -ATCp
> if [ $? -gt 1 ]; then
>
> my understanding is this part didn't need any modification in the
> updated script, again is this intentional?
>
>
> thanks
These are both unintentional typos. Neither one will break anything,
but you're right that it does look confusing.
[ -x $SCRIPT ]; and [ -x "$SCRIPT" ]; are essentially the same, but
using the double quotes explicitly tells BASH to expand any characters
like * ? or ~ into filenames. It's probably best to use the double
quotes and not rely on BASH to guess if it should expand or not.
[ $(($?)) -gt $((1)) ]; and [ $? -gt 1 ]; are the same, but the former
is much more confusing to look at. The $(( )) notation tells BASH to
treat what is in the parentheses as a numerical value. However this is
redundant because -gt (greater than) is a numerical operator and using
it implies that we are dealing with numbers. So it is best to use the
easier to read [ $? -gt 1 ]; format.
If you want to gain some more insight into the notation the BASH manpage
has more detailed descriptions. There are also some manpages for the
original Bourne shell that are much more concise. You can find these on
the web or on an older, non-Linux, Unix box. When searching it is
important to note that many times the Bourne shell is called bsh instead
of just sh.
Dave
More information about the Pocket-Linux
mailing list