Re: [PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-29 Thread Eric Blake
On 06/29/2010 12:35 PM, Ralf Wildenhues wrote: > * Gary V. Vaughan wrote on Tue, Jun 29, 2010 at 08:30:43PM CEST: >> On 30 Jun 2010, at 01:22, Ralf Wildenhues wrote: >>> I think m4sh can simply use code like >>> >>> if ( eval '$smart_works' ) >/dev/null 2>&1; then >>>func_foo () { smart code;

Re: [PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-29 Thread Ralf Wildenhues
* Gary V. Vaughan wrote on Tue, Jun 29, 2010 at 08:30:43PM CEST: > On 30 Jun 2010, at 01:22, Ralf Wildenhues wrote: > > I think m4sh can simply use code like > > > > if ( eval '$smart_works' ) >/dev/null 2>&1; then > >func_foo () { smart code; } > > else > >func_foo () { safe code; } > >

Re: [PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-29 Thread Gary V. Vaughan
Hallo Ralf, On 30 Jun 2010, at 01:22, Ralf Wildenhues wrote: > * Gary V. Vaughan wrote on Tue, Jun 29, 2010 at 05:09:29PM CEST: >> On 29 Jun 2010, at 21:03, Eric Blake wrote: >>> Ultimately, I'd like to fix m4sh to make it easier to probe/require XSI >>> support, but that will have to wait until a

Re: [PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-29 Thread Ralf Wildenhues
Hi Gary, * Gary V. Vaughan wrote on Tue, Jun 29, 2010 at 05:09:29PM CEST: > On 29 Jun 2010, at 21:03, Eric Blake wrote: > > Ultimately, I'd like to fix m4sh to make it easier to probe/require XSI > > support, but that will have to wait until after autoconf 2.66. > > While that might turn out to b

Re: [PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-29 Thread Gary V. Vaughan
Hi Eric, On 29 Jun 2010, at 21:03, Eric Blake wrote: > On 06/29/2010 12:52 AM, Gary V. Vaughan wrote: > i=$((i+1)) >> >> I think we can't rely on the availability of $((expr)) :( > > Is there any shell that supports XSI but not $(()), seeing as how both > are mandated by POSIX? But we've al

Re: [PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-29 Thread Eric Blake
On 06/29/2010 12:52 AM, Gary V. Vaughan wrote: i=$((i+1)) > > I think we can't rely on the availability of $((expr)) :( Is there any shell that supports XSI but not $(()), seeing as how both are mandated by POSIX? But we've already come up with better alternatives, so this is a moot point.

Re: [PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-29 Thread Gary V. Vaughan
Hi Paolo, On 29 Jun 2010, at 15:21, Paolo Bonzini wrote: > On 06/29/2010 08:52 AM, Gary V. Vaughan wrote: >> func_split_short_arg () >> { >> arg="$1"; while test ${#arg} -gt 2; do arg="${arg%?}"; done >> rest=${1%??} >> } > > What about > > func_split_short_arg () { > rest=${1#??}; > arg=$

Re: [PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-29 Thread Paolo Bonzini
On 06/29/2010 08:52 AM, Gary V. Vaughan wrote: Well, really the problem is this: while $# -gt 0; do opt=$1; shift case $opt in -p) opt_p="$1"; shift ;; -q) opt_q="$1"; shift ;; -x) opt_x=: ;; -y) opt_y=: ;; -p*|-q*) # option args func_split_short_arg $opt

Re: [PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-28 Thread Gary V. Vaughan
Hi Eric, Thanks for the feedback! On 29 Jun 2010, at 05:37, Eric Blake wrote: > On 06/28/2010 04:19 PM, Ralf Wildenhues wrote: >> * Eric Blake wrote on Mon, Jun 28, 2010 at 02:49:40PM CEST: >>> tmp=${1#?} >>> patt= >>> i=2 >>> while test $i -lt ${#1}; do >>> patt="?$patt" >> >> If the parameter

Re: [PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-28 Thread Eric Blake
On 06/28/2010 04:19 PM, Ralf Wildenhues wrote: > Hi Eric, > > thanks for the suggestion. I had considered the idea for a second, but > failed to see the nontrivial half. > > * Eric Blake wrote on Mon, Jun 28, 2010 at 02:49:40PM CEST: >> tmp=${1#?} >> patt= >> i=2 >> while test $i -lt ${#1}; do >

Re: [PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-28 Thread Ralf Wildenhues
Hi Eric, thanks for the suggestion. I had considered the idea for a second, but failed to see the nontrivial half. * Eric Blake wrote on Mon, Jun 28, 2010 at 02:49:40PM CEST: > tmp=${1#?} > patt= > i=2 > while test $i -lt ${#1}; do > patt="?$patt" If the parameter may be expected to be very l

Re: [PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-28 Thread Eric Blake
ash-isms as: tmp=${1#?} patt= i=2 while test $i -lt ${#1}; do patt="?$patt" i=$((i+1)) done result=${tmp%$patt} Obviously, you'd want to pick better variable names due to namespace considerations... -- View this message in context: http://old.nabble.com/-PATCH--

Re: [PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-27 Thread Gary V. Vaughan
Hallo Ralf, Thanks for the review. On 27 Jun 2010, at 19:02, Ralf Wildenhues wrote: > * Gary V. Vaughan wrote on Sun, Jun 27, 2010 at 12:58:03PM CEST: >> Okay to push? > > No, ${parameter:offset} and ${parameter:offset:length} are bash specific > not XSI mandated. Ah, okay. Didn't think to loo

Re: [PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-27 Thread Ralf Wildenhues
* Gary V. Vaughan wrote on Sun, Jun 27, 2010 at 12:58:03PM CEST: > Okay to push? No, ${parameter:offset} and ${parameter:offset:length} are bash specific not XSI mandated. IIRC we already have a separate test for bash features that won't regress on non-bash XSI shells. Please add the test there.

[PATCH] Add an XSI replacement for func_split_short_opt.

2010-06-27 Thread Gary V. Vaughan
Okay to push? * libltdl/m4/libtool.m4 (_LT_CHECK_SHELL_FEATURES): Also ensure that XSI substring extraction is supported. (_LT_PROG_XSI_SHELLFNS): Use XSI substring extraction to split short options to avoid unnecessary forks if the host shell supports that. --- ChangeLog |7 +