ports/108948: ports/lang/stklos has bashism in installed scripts

clemens fischer ino-news at spotteswoode.dnsalias.org
Thu Feb 8 22:50:20 UTC 2007


>Number:         108948
>Category:       ports
>Synopsis:       ports/lang/stklos has bashism in installed scripts
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 08 22:50:19 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     clemens fischer
>Release:        FreeBSD 6.2-STABLE i386
>Organization:
>Environment:

System: FreeBSD spotteswoode.dnsalias.org 6.2-STABLE
FreeBSD 6.2-STABLE #15: Tue Feb 6 17:34:47 CET 2007
root at spotteswoode.dnsalias.org:/usr/obj/usr/src/sys/spott i386

>Description:

two of the bourne shell scripts installed by ports/lang/stklos contain
function definitions formulated the "bash-way", thus fail issueing
a syntax error.  the shebang line is "#!/bin/sh".  the definitions are
prefixed by the bash reserved word "function":

  /l/bin/stklos-ext-install:function usage()
  /l/bin/stklos-install:function usage()
  /l/bin/stklos-install:function trace()
  /l/bin/stklos-install:function try_fetch()
  /l/bin/stklos-install:function die()
  /l/bin/stklos-install:function find_prefix()
  /l/bin/stklos-install:function install_package()
  /l/bin/stklos-install:function uninstall_package()
  /l/bin/stklos-install:function list_extensions()

also, both scripts refer to the bash builtin variable "$UID", which has
to be replaced by "`id -u`".

>How-To-Repeat:

after installing lang/stklos, do:

  $ stklos-install
  /usr/local/bin/stklos-install: 37: Syntax error: "(" unexpected

the same goes for "/l/bin/stklos-ext-install".

>Fix:

$ rrcsdiff /l/bin/stklos-install
rcsdiff --unified /l/bin/stklos-install
===================================================================
RCS file: /l/bin/RCS/stklos-install,v
retrieving revision 1.1
diff --unified -r1.1 /l/bin/stklos-install
--- /l/bin/stklos-install       2007/02/08 22:25:47     1.1
+++ /l/bin/stklos-install       2007/02/08 22:27:50
@@ -34,7 +34,7 @@
 # ----------------------------------------------------------------------
 #      Usage ...
 # ----------------------------------------------------------------------
-function usage()
+usage()
 {
     cat <<EOF
 Usage: stklos-setup [OPTIONS] package
@@ -50,7 +50,7 @@
 # ----------------------------------------------------------------------
 #      trace ...
 # ----------------------------------------------------------------------
-function trace()
+trace()
 {
     case $TERM in
        vt100|xterm*|rxvt|urxvt*) begin=""; end="" ;;
@@ -62,7 +62,7 @@
 # ----------------------------------------------------------------------
 #      try-fetch ...
 # ----------------------------------------------------------------------
-function try_fetch()
+try_fetch()
 {
     pkg=$1
     trace "Package $pkg is absent. Try to fetch it from $DISTURL"
@@ -75,7 +75,7 @@
 # ----------------------------------------------------------------------
 #      die ...
 # ----------------------------------------------------------------------
-function die()
+die()
 {
     echo $1 >&2
     exit 1
@@ -85,9 +85,9 @@
 # ----------------------------------------------------------------------
 #      find_prefix ...
 # ----------------------------------------------------------------------
-function find_prefix()
+find_prefix()
 {
-    if [ $UID = 0 ] ;then
+    if [ `id -u` -eq 0 ] ;then
        echo "`stklos-config --prefix`/share/stklos/extensions"
     else
        echo $HOME/.stklos/ext/extensions
@@ -98,7 +98,7 @@
 # ----------------------------------------------------------------------
 #      install_package ...
 # ----------------------------------------------------------------------
-function install_package()
+install_package()
 {
     pkg=$1
     TMP=/tmp/stklos-setup-$$
@@ -116,7 +116,7 @@
        exit 1
     fi

-    if [ $UID = 0 ] ;then
+    if [ `id -u` -eq 0 ] ;then
        prefix=`stklos-config --prefix`
     else
        mkdir -p $HOME/.stklos
@@ -145,7 +145,7 @@
 # ----------------------------------------------------------------------
 #      uninstall_package ...
 # ----------------------------------------------------------------------
-function uninstall_package()
+uninstall_package()
 {
     pkg=$1

@@ -175,7 +175,7 @@
 # ----------------------------------------------------------------------
 #      list_extensions ...
 # ----------------------------------------------------------------------
-function list_extensions()
+list_extensions()
 {
     trace "Available extensions:"
     DIR=`find_prefix`

$ rrcsdiff /usr/local/bin/stklos-ext-install
rcsdiff --unified /usr/local/bin/stklos-ext-install
===================================================================
RCS file: /usr/local/bin/RCS/stklos-ext-install,v
retrieving revision 1.1
diff --unified -r1.1 /usr/local/bin/stklos-ext-install
--- /usr/local/bin/stklos-ext-install   2007/02/08 22:32:43     1.1
+++ /usr/local/bin/stklos-ext-install   2007/02/08 22:34:15
@@ -27,7 +27,7 @@
 #


-function usage()
+usage()
 {
     echo "Usage: $0 pkg file dir mode
 where
@@ -48,7 +48,7 @@
 MODE=$4

 # Create the destination directory
-if [ $UID = 0 ] ;then
+if [ `id -u` -eq 0 ] ;then
     DEST=`stklos-config -p`/$DIR
     DB=`stklos-config -p`/share/stklos/extensions
 else
@@ -69,7 +69,7 @@
 chmod $MODE $DEST/$FILE

 # Retain in our DB that this file was installed
-if [ $UID = 0 ] ;then
+if [ `id -u` -eq 0 ] ;then
     DBDIR=`stklos-config -p`/share/stklos/extensions
 else
     DBDIR=$HOME/.stklos/ext/extensions
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list