extfs shell scripts [was: Re: Call for development freeze]

Roland Illig roland.illig at gmx.de
Wed Nov 10 15:13:08 UTC 2004


Leonard den Ottolander wrote:
> Hello Roland,
> 
> On Wed, 2004-11-10 at 07:43, Roland Illig wrote:
> 
>>Here are some more issues regarding the VFS shell scripts.
> 
> 
>>--- vfs/extfs/audio.in	18 Oct 2004 02:20:09 -0000	1.8
>>-	A=`echo $A | sed -e 's/\.//' -e 's/^\(.\)$/0\1/'`
>>+	A=`echo "$A" | sed -e 's/\.//' -e 's/^\(.\)$/0\1/'`
> 
> 
> Unnecessary as the value of $A is only parsed, not passed to a shell,
> and not even interpreted by echo.

I always provide a single string to echo(1). $A could be splitted into 
many words and lose some whitespace. "$A" passes the value of $A 
literally to the command, $A interprets it.

>>-    if [ "$2" == "CDDB" ]; then
>>+    if [ x"$2" = x"CDDB" ]; then
> 
> More correct wrt old versions of bash. Ok.

This has nothing to do with bash. Let $2 be "-f". Then the [(1) command 
line looks like:
[ -f == CDDB ]

The "-f" is interpreted as the command to look for the existence of a 
regular file. Putting an "x" (or almost every other character) in front 
of the "-f" makes the "==" the command.


>>Index: vfs/extfs/trpm
>>-name=`sed 's/.*\///;s/\.trpm$//' "$2"`
>>+name=`echo "$2" | sed 's/.*\///;s/\.trpm$//'`

> Please explain. What's the use of putting an echo "$2" in front? Again,
> quotes are not needed here. And shouldn't this command include an -e in
> this case?

The sed command is most likely supposed to transform the value of $2, 
not the file named by $2.

The "-e" option is not necessary when passing exactly one command to sed.

> For the rest: Quoting of temporary file names is unnecessary as they
> have no spaces in their names, but technically correct, so ok.

What about MC_TMPDIR="/Users/Leonard den Ottolander/temp"? Currently 
most scripts will break, but I want them not to break. What if 
MC_TMPDIR="/tmp/foo /*"?

rm -rf $MC_TMPDIR

Roland



More information about the mc-devel mailing list