Re: [gentoo-user] Re: emerge of ksh93 erroring out.. who can interpret
[EMAIL PROTECTED] writes: So I'm interested in what I might run into. So far it looks like it would be ALMOST as easy as symlinking ksh to bash in /bin. Uh, this sounds scary :) The two big things I see that will cause that not to work are lots of calls to `print' and that bash does not understand the easy way you can create an array in ksh: `set -A array somecmd' creating an array of the output of somecmd. So the print calls and array creation would cause failure in nearly all my scripts. Someone on comp.unix.shell pointed out I could create a `print() { echo -e $@ }' function in bash and add that to my old ksh scripts. So that would cover the print calls in most cases but still pondering the array part. I do not know about ksh, but if the former statement creates an array with the i'th element containing the i'th word of somecmd's output, it should work like this: array=( $( somecmd ) ) If you need the i'th line, not the i'th word, do it like this, changing the internal field separator to newlines only: oldIFS=$IFS IFS=$'\n' array=( $( somecmd ) ) IFS=$oldIFS If you want to keep your notation, something like this might work. If the first parameter of a call to set is -A, it creates the array, or else it calls the bash set builtin: set () { if [[ $1 == -A ]] then eval $2=( $( $3 ) ) else set $@ fi } I don't have so many with array calls but enough that it would be some work to fix. But back to your comments. The bugs. [...] Can you cite some actual examples of what you are talking about, with enough detail so I can see what you mean? Maybe include one or two of the workarounds you are tired of dealing with? I also had trouble with some bash bugs(*), and have some workarounds in my scripts, in case they run with older bash versions. But as I cannot ensure the client systems run kash or zsh, I did not bother to learn them, and chose bash as my shell. It's amazing what it can do, but I guess zsh and ksh can do the same, or even more. (*) One was that I once needed to escape backslashes in ${//...} notations, but now I must not do so any more: (( BASH_VERSINFO 3 )) ospath=${1////} || ospath=${1//\\//} The other problem was with the =~ notation and quoting of the regular expression not being allowed any more. Workaround is to define a variable (foo) with the expression: [[ blabla =~ $foo ]] Wonko -- gentoo-user@lists.gentoo.org mailing list
[gentoo-user] Re: emerge of ksh93 erroring out.. who can interpret
Alex Schuster [EMAIL PROTECTED] writes: [EMAIL PROTECTED] writes: So I'm interested in what I might run into. So far it looks like it would be ALMOST as easy as symlinking ksh to bash in /bin. Uh, this sounds scary :) Yeah, it would be on a system with actual users but here its just me, myself and I. So all that is effected are the ksh scripts I've written and currently use in various places (none are system show stoppers). But I was really just saying that syntax at my low level of usage is largely interchangeable but for the cases I mentioned. So it makes switching scripting shells from ksh93 to bash pretty smooth. [...] (for searchers who hit this discussion: I've snipped out very nice information showing how to do ksh93 style `set -A arrary cmd' in bash... and related interesting syntax See Alex S previous message in this thread at Message-ID: [EMAIL PROTECTED]) I also had trouble with some bash bugs(*), and have some workarounds in my scripts, in case they run with older bash versions. But as I cannot ensure the client systems run kash or zsh, I did not bother to learn them, and chose bash as my shell. It's amazing what it can do, but I guess zsh and ksh can do the same, or even more. Pretty much summarizes why I'm switching to bash too. Instead of learning the suggested (in this thread) zsh or staying with ksh93. Something for your consideration I learned on comp.unix.shell that ksh93 can handle associative arrays where as bash cannot or maybe just not as easily. The example given by Icarus S. there for ksh93 was: From: Icarus Sparry [EMAIL PROTECTED] Subject: Re: internal alias Newsgroups: comp.unix.shell Date: 11 Jan 2008 17:23:20 GMT Message-ID: [EMAIL PROTECTED] typeset -A wives wives[fred]=wilma wives[barny]=betty while read husband do case ${wives[$husband]} in ) echo Single;; *) echo Married to ${wives[$husband]} ;; esac done You may find that discussion interesting The other problem was with the =~ notation and quoting of the regular expression not being allowed any more. Workaround is to define a variable (foo) with the expression: [[ blabla =~ $foo ]] I can't reproduce that here (I mean a problem with quoting the regex) but maybe I'm not getting what you mean? Or maybe its been fixed. bash --version GNU bash, version 3.2.17(1)-release (i686-pc-linux-gnu) reader if [[ bla =~ bl ]];then echo MATCH;fi MATCH reader if [[ bla =~ bl ]];then echo MATCH;fi MATCH -- gentoo-user@lists.gentoo.org mailing list
[gentoo-user] Re: emerge of ksh93 erroring out.. who can interpret
[EMAIL PROTECTED] writes: Alex Schuster [EMAIL PROTECTED] writes: [EMAIL PROTECTED] writes: But I was really just saying that syntax at my low level of usage is largely interchangeable but for the cases I mentioned. So it makes switching scripting shells from ksh93 to bash pretty smooth. Well, good luck then :) Something for your consideration I learned on comp.unix.shell that ksh93 can handle associative arrays where as bash cannot or maybe just not as easily. The example given by Icarus S. there for ksh93 was: [...] You may find that discussion interesting Yeah, this is one of the things I would also like very much to have. But the Bash FAQ (http://tiswww.case.edu/php/chet/bash/FAQ) not only states that bash lacks this feature (C2), but also says that this is planned for the future (H3). So I wait and hope it will happen soon. Well. Eventually. The other problem was with the =~ notation and quoting of the regular expression not being allowed any more. Workaround is to define a variable (foo) with the expression: [[ blabla =~ $foo ]] I can't reproduce that here (I mean a problem with quoting the regex) but maybe I'm not getting what you mean? Or maybe its been fixed. [...] In bash 3.2, [[ 1 =~ 1|2|3 ]] worked and evaluated to true, but [[ 1 =~ 1|2|3 ]] gave a syntax error. In bash = 3.2, [[ 1 =~ 1|2|3 ]] does not match any longer, only [[ 1 =~ 1|2|3 ]] does. The workaround is to define a variable foo, and use [[ 1 =~ $foo ]]. Wonko -- gentoo-user@lists.gentoo.org mailing list
[gentoo-user] Re: emerge of ksh93 erroring out.. who can interpret
Matthias B. [EMAIL PROTECTED] writes: On Tue, 08 Jan 2008 20:32:46 -0600 [EMAIL PROTECTED] wrote: I'm beginning to think I may just drop ksh93. Unfortunately, I've grown quite accustomed to using `print' instead of `echo -e' so I will have to replace that in a couple dozen scripts... otherwise the scripts seem to run fine under bash. (so far.. I haven't tested all of them yet) Have you tried zsh? I've found it to be much better for scripting than bash, especially less buggy. And it has a print builtin :-) I have yes. However it was many years ago. Probably at least 9 yrs ago. I don't know much now but back then I knew even less. Linux was a labor of love back then. I tried zsh and was thoroughly confused by it. It actually seemed too capable for my meager skills. I never went back. Currently it appears that for my level of usage ksh93 or bash are about the same... I'm rethinking my choice of scripting shell. Mainly because of running into trouble getting it installed. (Alan M. has solved that problem for me too. And it installed without problems when I unmasked it Thank you Alan) On examining current bash I see all the reasons I used ksh93 are now possible in bash... the =~ operator is something I use a lot. I don't now when that entered bash but its there now. Can you say why you think zsh is better? -- gentoo-user@lists.gentoo.org mailing list
[gentoo-user] Re: emerge of ksh93 erroring out.. who can interpret
Matthias B. [EMAIL PROTECTED] writes: On Fri, 11 Jan 2008 11:18:44 -0600 [EMAIL PROTECTED] wrote: Can you say why you think zsh is better? The bugs. I've hit lots of bash bugs in the past and every version seems to fix some bugs and introduce new ones. I'm tired of adding new workarounds to my scripts whenever I update bash. I hope this doesn't come off as just being picky but my perspective is that of someone who is about to switch from using ksh93 as main scripting shell to bash. So I'm interested in what I might run into. So far it looks like it would be ALMOST as easy as symlinking ksh to bash in /bin. The two big things I see that will cause that not to work are lots of calls to `print' and that bash does not understand the easy way you can create an array in ksh: `set -A array somecmd' creating an array of the output of somecmd. So the print calls and array creation would cause failure in nearly all my scripts. Someone on comp.unix.shell pointed out I could create a `print() { echo -e $@ }' function in bash and add that to my old ksh scripts. So that would cover the print calls in most cases but still pondering the array part. I don't have so many with array calls but enough that it would be some work to fix. But back to your comments. The bugs. [...] Can you cite some actual examples of what you are talking about, with enough detail so I can see what you mean? Maybe include one or two of the workarounds you are tired of dealing with? -- gentoo-user@lists.gentoo.org mailing list
Re: [gentoo-user] Re: emerge of ksh93 erroring out.. who can interpret
On Fri, 11 Jan 2008 11:18:44 -0600 [EMAIL PROTECTED] wrote: Can you say why you think zsh is better? The bugs. I've hit lots of bash bugs in the past and every version seems to fix some bugs and introduce new ones. I'm tired of adding new workarounds to my scripts whenever I update bash. MSB -- My vacuum cleaner can't swallow bananas. -- gentoo-user@lists.gentoo.org mailing list
Re: [gentoo-user] Re: emerge of ksh93 erroring out.. who can interpret
On Fri, 11 Jan 2008 12:56:11 -0600 [EMAIL PROTECTED] wrote: Can you cite some actual examples of what you are talking about, with enough detail so I can see what you mean? Maybe include one or two of the workarounds you are tired of dealing with? One thing I encountered is this bug echo $(echo $';foo') bash: foo: command not found introduced with some 3.1 version. Then at some point the following stopped working for d in `echo $locdirs | sed -e 's#/# #g'`; do because bash stupidly regarded the embedded # as comment delimters and complained about not finding the closing backtick. Both bugs are fixed now. Both cases broke scripts that I had released as part of a project and therefore caused bug reports against my script. There were others but I don't have the time to dig them out. I'm not trying to convince you to stay away from bash, just telling you my reasons. Oh, I forgot to mention that I found the zsh developers much easier to get in touch with and much more responsive about bug reports. But all of this is off-topic for gentoo-user, so I'll stop now. MSB -- The biggest fallacy of the SETI project is the belief that TV signals are a sign of intelligence! -- gentoo-user@lists.gentoo.org mailing list
Re: [gentoo-user] Re: emerge of ksh93 erroring out.. who can interpret
On Tue, 08 Jan 2008 20:32:46 -0600 [EMAIL PROTECTED] wrote: I'm beginning to think I may just drop ksh93. Unfortunately, I've grown quite accustomed to using `print' instead of `echo -e' so I will have to replace that in a couple dozen scripts... otherwise the scripts seem to run fine under bash. (so far.. I haven't tested all of them yet) Have you tried zsh? I've found it to be much better for scripting than bash, especially less buggy. And it has a print builtin :-) MSB -- When you think you think, you only think that you think. Don't you think? -- gentoo-user@lists.gentoo.org mailing list
[gentoo-user] Re: emerge of ksh93 erroring out.. who can interpret
Alan McKinnon [EMAIL PROTECTED] writes: [...] Can anyone interpret this emerge failure and have some educated guesses what I should do to get it to compile. That message follows the eix output below. http://forums.gentoo.org/viewtopic-p-4210019.html?sid=a282fd302189d24b214267ec5b90 especially last 4 posts Apparently it's a bug, and has been fixed in later versions. You are using a stable 2004 version, in your position I would unmask ksh and emerge the latest unstable I see... thanks. That does sound like a way around it., I may just start using bash instead for the future... Having this happen has made me rethink my ( non-thought out) choice of shells. I see where it can cause some grief at a time when you don't want to be horsing around with that kind of problem. I'm not a very sophisticated shell script programmer. One thing I liked about ksh93 was its ability to match on regex. Something bash couldn't do not so long ago. I haven't been paying attention to bash development but having this problem, I did start investigating and finding that modern bash can do most if not all of what I liked about ksh93. It can match like this if [[ $1 =~ ^[0-9]+$ ]];then [...] fi Forcing a match of number only by regex. Instead of trying to do it with a pattern match. And a sort of double reverse loop de loop negation I sometimes find useful. (since there is no `!~' operator like perl or awk) if [[ ! ( $1 =~ ^[0-9]+$ )]];then [...] fi I'm beginning to think I may just drop ksh93. Unfortunately, I've grown quite accustomed to using `print' instead of `echo -e' so I will have to replace that in a couple dozen scripts... otherwise the scripts seem to run fine under bash. (so far.. I haven't tested all of them yet) -- gentoo-user@lists.gentoo.org mailing list