Incorrect manage "*" in test -z

2015-04-16 Thread Guillermo Buritica Tobon
Hi All. H have the next bash script code.: #!/bin/sh # Pring OK on empty input, # Print input on non-empty input read INPUT if [ -z "$INPUT" ]; then echo OK else echo $INPUT while read INPUT; do echo $INPUT done fi The function read one input and

Re: Incorrect manage "*" in test -z

2015-04-16 Thread Guillermo Buritica Tobon
Sorry I forgot the main version. I have tested in: all show the same issue. *** LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch Red Hat Ente

Re: [Help-bash] make function local

2015-04-16 Thread Linda Walsh
Pierre Gaston wrote: > Is there a particular problem you're trying to solve for which local > functions would be the appropriate solution? Cleanliness. Not polluting the global namespace. Ensuring the function can't be called from outside a function. It's a trite example, but

Re: [Help-bash] make function local

2015-04-16 Thread Chet Ramey
On 4/16/15 11:43 AM, Dan Douglas wrote: > I thought Bash always first splits the identifier from the subscript, > then checks which attributes the variable has set. If it has the > associative array attribute plus a subscript then the subscript is > only processed for expansions and the resulting s

Bash performance when declaring variables (was: Re: [Help-bash] make function local)

2015-04-16 Thread Eduardo A . Bustamante López
On Thu, Apr 16, 2015 at 11:07:34AM -0400, Chet Ramey wrote: [...] > I knew that rang a bell somewhere. mt_hash is a function in the bash > malloc library that keeps track of all allocations and deallocations in > a table. It's part of the debugging that is enabled when you build from > the devel

Re: [Help-bash] make function local

2015-04-16 Thread Dan Douglas
I thought Bash always first splits the identifier from the subscript, then checks which attributes the variable has set. If it has the associative array attribute plus a subscript then the subscript is only processed for expansions and the resulting string is used as the key. If the associative arr

Re: [Help-bash] make function local

2015-04-16 Thread Chet Ramey
On 4/12/15 5:56 PM, Eduardo A. Bustamante López wrote: > Oh, you already have lots of things to do to bother with this :-) > > Anyways, I'll expand them. > > On Fri, Apr 10, 2015 at 04:35:25PM -0400, Chet Ramey wrote: >> On 4/10/15 10:13 AM, Eduardo A. Bustamante López wrote: >> >>> - a faster im

Re: [Help-bash] make function local

2015-04-16 Thread Chet Ramey
On 4/12/15 5:56 PM, Eduardo A. Bustamante López wrote: > Oh, you already have lots of things to do to bother with this :-) > > Anyways, I'll expand them. > > On Fri, Apr 10, 2015 at 04:35:25PM -0400, Chet Ramey wrote: >> On 4/10/15 10:13 AM, Eduardo A. Bustamante López wrote: >> >>> - a faster im

Re: Request to a new feature on read

2015-04-16 Thread Dan Douglas
On Thu, Apr 16, 2015 at 9:50 AM, Greg Wooledge wrote: > I don't see why such features should be compiled into bash's read builtin. > I'd have no problem with adding better splitting/joining/parsing features > in a more general context, probably operating on a string variable, but > certainly not o

Re: Request to a new feature on read

2015-04-16 Thread Greg Wooledge
On Thu, Apr 16, 2015 at 09:39:08AM -0500, Dan Douglas wrote: > On Thu, Apr 16, 2015 at 9:32 AM, Greg Wooledge wrote: > > On Thu, Apr 16, 2015 at 09:29:56AM -0500, Dan Douglas wrote: > >> I find myself in need of something along the lines of Python's > >> `re.split` and `re.findall` all the time. E

Re: Request to a new feature on read

2015-04-16 Thread Valentin Bajrami
While I was developing a small script, I thought about how to use -N flag to a greater extent. Although -N in its own is very limited. It does serve the purpose but not what I need. I also discussed this in #bash freenode, and got some ideas like: pgas: while read -n1 d;do case $d in '')brea

Re: Request to a new feature on read

2015-04-16 Thread Greg Wooledge
On Thu, Apr 16, 2015 at 09:29:56AM -0500, Dan Douglas wrote: > I find myself in need of something along the lines of Python's > `re.split` and `re.findall` all the time. E.g. splitting an ip into an > array of octets. IFS=. read -ra octets <<< "$ip"

Re: Request to a new feature on read

2015-04-16 Thread Dan Douglas
On Thu, Apr 16, 2015 at 9:32 AM, Greg Wooledge wrote: > On Thu, Apr 16, 2015 at 09:29:56AM -0500, Dan Douglas wrote: >> I find myself in need of something along the lines of Python's >> `re.split` and `re.findall` all the time. E.g. splitting an ip into an >> array of octets. > > IFS=. read -ra oc

Re: Request to a new feature on read

2015-04-16 Thread Dan Douglas
On Thu, Apr 16, 2015 at 8:55 AM, Eduardo A. Bustamante López wrote: > Any reason to justify this instead of using a simple loop? I find myself in need of something along the lines of Python's `re.split` and `re.findall` all the time. E.g. splitting an ip into an array of octets. On Thu, Apr 16,

Re: Request to a new feature on read

2015-04-16 Thread Eduardo A . Bustamante López
Any reason to justify this instead of using a simple loop? -- Eduardo Bustamante https://dualbus.me/

Request to a new feature on read

2015-04-16 Thread Valentin Bajrami
Hi, According to ''help read'' we can specify -N[chars] to trigger return automatically. Is it possible to approach read differently? For example: $re is some regular expression read -N$re -p "Enter two or three digits to continue " getInput The above is much of a pseudo-code but I hope you