Skip to contentSkip to conversation

Remove bashism from src/mlmmj-make-ml.sh.in

PATCH In review Thomas Goirand 4 participants 6 messages Jan 22, 2012 – Jan 23, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove bashism from src/mlmmj-make-ml.sh.in

Hi,

src/mlmmj-make-ml.sh.in declares it uses sh and not bash, but it has bashism which may fail if dash is the default implementation for sh (which is the case now in both Debian and Ubuntu).

Please apply the attached patch which removes bashism in src/mlmmj-make-ml.sh.in. I've been carrying this patch for too long, and I'd like to have it removed from the debian/patches folder for the next release of MLMMJ.

Thanks,

Thomas Goirand (zigo)

From: <[email protected]>
Subject: Remove bashisms from make-mlmmj-ml script.
Forwarded: no

src/mlmmj-make-ml.sh.in +3 -2
diff -urNad a/src/mlmmj-make-ml.sh.in b/src/mlmmj-make-ml.sh.in
@@ -21,7 +21,7 @@
 do
 case "$Option" in 
 	h )
-	echo -e "$USAGE"
+	echo "$USAGE"
 	exit 0
 	;;
 	z )
@@ -42,7 +42,8 @@
 	CHOWN="$OPTARG"
 	;;
 	* )
-	echo -e "$0: invalid option\nTry $0 -h for more information."
+	echo "$0: invalid option"
+	echo "Try $0 -h for more information."
 	exit 1
 esac
 done
#1 lore raw

src/mlmmj-make-ml.sh.in line 46

Quoted 3 lines · Thomas Goirand
src/mlmmj-make-ml.sh.in +2 -1
-	echo -e "$0: invalid option\nTry $0 -h for more information."
+	echo "$0: invalid option"
+	echo "Try $0 -h for more information."

Better yet, use a single command:
- echo -e "$0: invalid option\nTry $0 -h for more information."
+ printf "$0: invalid option\nTry $0 -h for more information.\n"

M.

#2 lore raw
In reply to Thomas Goirand

Review

Quoted 10 lines · Mark Alan

src/mlmmj-make-ml.sh.in line 46

Quoted 3 lines · Thomas Goirand
src/mlmmj-make-ml.sh.in +2 -1
-	echo -e "$0: invalid option\nTry $0 -h for more information."
+	echo "$0: invalid option"
+	echo "Try $0 -h for more information."

Better yet, use a single command:

(quoted diff) +1 -1
-	echo -e "$0: invalid option\nTry $0 -h for more information."
+	printf "$0: invalid option\nTry $0 -h for more information.\n"

Are you sure this is sh compatible?

I wonder if the echo version is perhaps more readable, and thus preferable anyway, rather than single-command wizardry. What do you think?

Ben.

#3 lore raw
In reply to Thomas Goirand
Quoted 1 line · Ben Schmidt

Are you sure this is sh compatible?

Yes, printf is a standard posix utility and actually less susceptible to the echo builtin in various shells.

Quoted 3 lines

I wonder if the echo version is perhaps more readable, and thus preferable anyway, rather than single-command wizardry. What do you think?

I would prefer two echos myself.

#4 lore raw
In reply to Thomas Goirand
Quoted 8 lines · Ben Schmidt
Quoted 7 lines · Mark Alan
Quoted 3 lines · Thomas Goirand
src/mlmmj-make-ml.sh.in +2 -1
-    echo -e "$0: invalid option\nTry $0 -h for more information."
+    echo "$0: invalid option"
+    echo "Try $0 -h for more information."
Quoted 5 lines

Review

Quoted 3 lines

Better yet, use a single command:

(quoted diff) +1 -1
-    echo -e "$0: invalid option\nTry $0 -h for more information."
+    printf "$0: invalid option\nTry $0 -h for more information.\n"

Are you sure this is sh compatible?

The Debian "checkbashisms" script doesn't report any error with it.

Quoted 3 lines

I wonder if the echo version is perhaps more readable, and thus preferable anyway, rather than single-command wizardry. What do you think?

I agree.

Thomas

#5 lore raw
In reply to Thomas Goirand
Quoted 7 lines
Quoted 5 lines

Review

Quoted 3 lines

Better yet, use a single command:

(quoted diff) +1 -1
-    echo -e "$0: invalid option\nTry $0 -h for more information."
+    printf "$0: invalid option\nTry $0 -h for more information.\n"

Are you sure this is sh compatible?

The Debian "checkbashisms" script doesn't report any error with it.

Thanks to you and everyone else who confirmed this for me. It is greatly appreciated.

Quoted 5 lines
Quoted 3 lines

I wonder if the echo version is perhaps more readable, and thus preferable anyway, rather than single-command wizardry. What do you think?

I agree.

I think the majority has this view.

I'm pushing the change out now.

Ben.