Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 191941 - app-i18n/canna - initscript uses bashisms
Summary: app-i18n/canna - initscript uses bashisms
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: CJK Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-10 06:39 UTC by Mathias Laurin
Modified: 2009-09-21 02:55 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
diff canna.old canna (canna.patch,295 bytes, patch)
2007-09-10 06:42 UTC, Mathias Laurin
Details | Diff
diff -u canna.old canna (SpanKY) (patch,644 bytes, patch)
2007-09-10 08:09 UTC, Mathias Laurin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mathias Laurin 2007-09-10 06:39:31 UTC
/etc/init.d/canna, from app-i18n/canna-3.7_p3 uses bashism for argument parsing and fails with (at least) dash, which I am using for /bin/sh

Reproducible: Always

Steps to Reproduce:
1. emerge app-i18n/canna dash
2. have /bin/sh point to /bin/dash
3. /etc/init.d/canna start

Actual Results:  
Syntax error: Bad substitution

Expected Results:  
15:32 /etc/init.d [0]0 # ./canna start
 * Starting canna ...                                                                                                [ ok ]
15:32 /etc/init.d [0]0 # ./canna stop 


I have fixed it locally by changing the bash-style command substitution with grep. I will post my diff in the next post (although I am no POSIX-shell expert, so the baselayout team may have a better way of doing it). And I use [ -n "$TEST" ] and [ -z "$TEST" ] but I do not know whether this is POSIX-compliant.
Comment 1 Mathias Laurin 2007-09-10 06:42:22 UTC
Created attachment 130462 [details, diff]
diff canna.old canna
Comment 2 Mathias Laurin 2007-09-10 06:45:13 UTC
(In reply to comment #1)
> Created an attachment (id=130462) [edit]
> diff canna.old canna
> 

PS: if you do not go with my patch, be careful that one test is testing if the option is *present* and the other one if the option is *absent*.
Comment 3 SpanKY gentoo-dev 2007-09-10 07:05:19 UTC
ugh, dont do anything like that

grep has the ability to function silently and return proper exit code, so you want to do:
if echo "${CANNASERVER_OPT}" | grep -qs -e"-u" ; then

also, in the future, post *unified* diffs, not context diffs
Comment 4 Mathias Laurin 2007-09-10 08:09:54 UTC
Created attachment 130480 [details, diff]
diff -u canna.old canna (SpanKY)

I did not about this grep feature, it is nice! thank you.

So here is the update using SpanKY's way and diff -u; that should be it.
Comment 5 Roy Marples (RETIRED) gentoo-dev 2007-09-10 08:54:10 UTC
Why use grep? Use a case statement to save on forking an external binary

case "${CANNASERVER_OPTS}" in
  *-syslog*) ;;
  *)
      case "${CANNASERVER_OPTS}" in
         *-u*) ;;
         *) ;;
      esac
      ;;
esac

However, all the above do inexact pattern matching, so you may want something like this

local have_syslog=false have_u=false
eval set -- "${CANNASERVER_OPTS}"
for opt in "$@"; do
   case "${opt}" in
      -syslog) have_syslog=true;;
      -u) have_u=true;;
   esac
done

And then use those vars accordingly.
Comment 6 MATSUU Takuto (RETIRED) gentoo-dev 2009-09-21 02:55:31 UTC
fixed in 3.7_p3-r1.