Prev: Continuous wifi errors
Next: How to trick my Debian in thinking that a package is not installed
From: Wes Garland on 20 Apr 2010 11:00 Hi, List! I have a few simple questions for you: 1 - I there a better place to get help with dash 2 - Is there way to detect that a script is running as dash, instead of a shell like Solaris' /bin/sh 3 - Corollary to #2, can I expect dash-as-sh to by a hard link or a sym link? (I would think not, but don't know Debian's policy here) 4 - Reason for #2, is there a way to list all functions declared in a script with dash? Under Solaris' shell, bash, or the korn shell I can use "typeset" -- I've searched POSIX and don't see a way that doesn't involve parsing the script. Thanks, Wes -- Wesley W. Garland Director, Product Development PageMail, Inc. +1 613 542 2787 x 102
From: Boyd Stephen Smith Jr. on 20 Apr 2010 11:20 On Tuesday 20 April 2010 09:57:14 Wes Garland wrote: > 1 - I there a better place to get help with dash Not that I know of. However, dash is fairly plain when it comes to POSIX- compliant shells. It handles the stuff POSIX requires it to plus the "local" keyword (which Debian requires of it) and that is about it. > 2 - Is there way to detect that a script is running as dash, instead of a > shell like Solaris' /bin/sh Not portably. It might be possible by parsing ($SHELL -V -c 'exit 123') or ($SHELL --version -c 'exit 123'). > 3 - Corollary to #2, can I expect dash-as-sh to by a hard link or a sym > link? (I would think not, but don't know Debian's policy here) I think it is via symlink. I don't think it uses the alternatives system. > 4 - Reason for #2, is there a way to list all functions declared in a > script with dash? Under Solaris' shell, bash, or the korn shell I can use > "typeset" -- I've searched POSIX and don't see a way that doesn't involve > parsing the script. Sorry, I don't even see a good way to tell if a function with a particular name is defined, but less list all the functions in the current shell environment. Bash is still an essential package last I checked. You might simply use /bin/bash and whatever bash-isms you like. -- Boyd Stephen Smith Jr. ,= ,-_-. =. bss(a)iguanasuicide.net ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.net/ \_/
From: Wes Garland on 20 Apr 2010 11:40 Hi, Boyd! On Tue, Apr 20, 2010 at 11:18 AM, Boyd Stephen Smith Jr. < bss(a)iguanasuicide.net> wrote: > > Not portably. It might be possible by parsing ($SHELL -V -c 'exit 123') or > ($SHELL --version -c 'exit 123'). > Say, that's a clever approach, thanks for suggesting it. Sorry, I don't even see a good way to tell if a function with a particular > name is defined, but less list all the functions in the current shell > environment. > Can you clarify? Listing all the functions in the current shell environment solves my issue perfectly.. But less is just a pager, no? Oh, wait, did you mean "much less list"? In which case, we're in the same boat, but I'm hoping there is a solution I'm not aware of (even though my hopes are dim :) ) > Bash is still an essential package last I checked. You might simply use > /bin/bash and whatever bash-isms you like. > > That would work pretty much everywhere except bone-stock Solaris, where I have no possibility of recovery -- "/bin/bash: bad interpreter: No such file or directory". At least if I use /bin/sh as my interpreter, I can always at the very least output an error message. I suppose my other alternative is roughly [ -x /bin/bash ] && /bin/bash $0 $* && exit $?, and assume that everywhere-but-solaris has /bin/bash. Hmm. If debian keeps bash around as a default package, even when dash-is-bin-sh, then I guess I'm in fairly safe territory in that regard. Thanks, Wes -- Wesley W. Garland Director, Product Development PageMail, Inc. +1 613 542 2787 x 102
From: Vincent Lefevre on 22 Apr 2010 07:10 On 2010-04-20 11:37:31 -0400, Wes Garland wrote: > > Bash is still an essential package last I checked. You might simply use > > /bin/bash and whatever bash-isms you like. > > > That would work pretty much everywhere except bone-stock Solaris, > where I have no possibility of recovery -- "/bin/bash: bad > interpreter: No such file or directory". That wouldn't even work everywhere under Linux. For instance, bash isn't installed by default on Maemo. > I suppose my other alternative is roughly [ -x /bin/bash ] && /bin/bash $0 > $* && exit $?, and assume that everywhere-but-solaris has /bin/bash. Hmm. [ -x /bin/bash ] && exec /bin/bash -- "$0" ${1+"$@"} But you also need to detect whether you are not running bash via this line, otherwise you'll get an infinite loop. I think this can be done with an environment variable, something like: [ "$RUNNING_BASH" = yes ] || [ -x /bin/bash ] && \ exec env RUNNING_BASH=yes /bin/bash -- "$0" ${1+"$@"} (not tested). You can also test features, like in: ( [[ -n 1 && -n 2 ]] ) 2> /dev/null || exec bash -- "$0" ${1+"$@"} > If debian keeps bash around as a default package, even when > dash-is-bin-sh, then I guess I'm in fairly safe territory in that > regard. It would probably remain as a default package, but I don't see why it should remain as essential in the long term. -- Vincent Lef�vre <vincent(a)vinc17.net> - Web: <http://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / Ar�naire project (LIP, ENS-Lyon) -- To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org Archive: http://lists.debian.org/20100422105156.GA7570(a)prunille.vinc17.org
From: Chris Davies on 21 Apr 2010 05:30 Wes Garland <wes(a)page.ca> wrote: > 2 - Is there way to detect that a script is running as dash, instead of a > shell like Solaris' /bin/sh If you write your script portably it will work with /bin/sh, for many values of sh. If you rely on features of ksh or bash you should specify one of those shells on the #! line. > 4 - Reason for #2, is there a way to list all functions declared in a script > with dash? "set" works for ksh, bash, and dash. On (at least) Solaris 9 & 10 and Debian. Is that enough? Chris -- To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org Archive: http://lists.debian.org/75r2a7xre1.ln2(a)news.roaima.co.uk
|
Next
|
Last
Pages: 1 2 Prev: Continuous wifi errors Next: How to trick my Debian in thinking that a package is not installed |