Following symlinks in globstar

2013-08-01 Thread Chris Down
As we're probably all aware, `globstar' follows symlinks when doing recursive
traversal. Is it possible to, at some future version, have an option that
enables/disables (I guess enables by default for backwards compatibility)
following symlinks? This can be quite irritating when trying to traverse procfs
filesystems especially.


pgpO4Jthz0k3z.pgp
Description: PGP signature


ldapscripts unusable from within a 'while read line' loop

2013-08-01 Thread Lakshminarasimhan Srinivasan

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VEND$
uname output: Linux win7082 3.2.0-4-amd64 #1 SMP Debian 3.2.41-2+deb7u2 
x86_64 GNU/Linux

Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.2
Patch Level: 37
Release Status: release

Description:
ldapscripts do not work from inside a while read line loop. 
The exact same scripts were working fine until the last upgrade


Repeat-By:
Prerequisite: ldapscripts installed.
Open a new bash script and type in the following:
-
#!/bin/bash
echo Testing if it works outside of the loop
ldapid
echo Getting into the read line loop
while read line
do
  ldapid
done Some file

The 'ldapid' command, which works outside of the loop, does not work 
from within. This time it throws an error Cannot guess user. Now we 
check an alternative:

Create a new script and type in the following:

#!/bin/bash
echo Testing if it works outside of the loop
ldapid
readarray lines  some file
echo Getting into the for loop
for line in ${lines[@]}
do
  ldapid
done
---
In this case 'ldapid' works both times. In fact, ldapid works in every 
other loop except a 'while read line' and I really do not have any idea why.


Many thanks for having a look,
Laks




Re: ldapscripts unusable from within a 'while read line' loop

2013-08-01 Thread Lakshminarasimhan Srinivasan


On 08/01/2013 04:09 PM, Greg Wooledge wrote:

On Thu, Aug 01, 2013 at 09:37:38AM +0200, Lakshminarasimhan Srinivasan wrote:

 ldapscripts do not work from inside a while read line loop.
The exact same scripts were working fine until the last upgrade
-
#!/bin/bash
echo Testing if it works outside of the loop
ldapid
echo Getting into the read line loop
while read line
do
   ldapid
doneSome file


This sounds like a change was made to whatever package ldapid is in.
If ldapid reads from standard input, it will conflict with the use of
stdin by read.

You can work around the problem by doing something like this:

while read line3
do
   ldapid
done 3  Some file

This way, read isn't using the same stdin file descriptor that ldapid is
(presumably) using.

This is not a bash bug.  It may or may not be an ldapid bug, as I have
no idea what that program does.
Can confirm that work around worked perfectly. I thought it was after a 
change in 'read', very sorry about the false report and many thanks to 
both you and Chris F.A. Johnson for taking the time to answer.


Cheers,
Laks





Re: Misleading phrasing about $! in documentation

2013-08-01 Thread Chet Ramey
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 7/31/13 5:17 AM, Chris Down wrote:
 I think our documentation on $! is a little misleading. `man bash' states:
 
 Special Parameters
 The shell treats several parameters specially. These parameters may 
 only
 be referenced; assignment to them is not allowed.
 
 [...]
 
 ! Expands to the process ID of the most recently executed background
 (asynchronous) command.

How about the command (or job) most recently placed in the background.

Chet

- -- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlH6gMMACgkQu1hp8GTqdKssxwCgjcqgNVFL/5D6G3F5NhSBV1MX
Eg4An1FdeVp2YpGd1vcpKuwqh3epnfao
=Foi3
-END PGP SIGNATURE-



Re: Misleading phrasing about $! in documentation

2013-08-01 Thread Chris Down
On 2013-08-01 11:37, Chet Ramey wrote:
 How about the command (or job) most recently placed in the background.

That works for me. I'd be more inclined to use job since it avoids confusion
about what happens when backgrounding a pipeline.

Thanks.


pgp2RdgUre66e.pgp
Description: PGP signature


Re: no apostrophe allowed in comment

2013-08-01 Thread Chet Ramey
On 7/30/13 7:04 PM, Curtis Doty wrote:

 The above works. Whereas the below fails.
 
 #! /bin/bash -ex
 #
 
 tee (
 # ain't this nifty
 echo hi there
 )
 
 It burps thusly:
 
 ./foo.sh: line 7: bad substitution: no closing `)' in (
 # ain't this nifty
 echo hi there
 )

Hi.  This was fixed a while back (5/2011), and the fix is in bash-4.3-
alpha.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: ldapscripts unusable from within a 'while read line' loop

2013-08-01 Thread Greg Wooledge
On Thu, Aug 01, 2013 at 09:37:38AM +0200, Lakshminarasimhan Srinivasan wrote:
 ldapscripts do not work from inside a while read line loop. 
 The exact same scripts were working fine until the last upgrade

 -
 #!/bin/bash
 echo Testing if it works outside of the loop
 ldapid
 echo Getting into the read line loop
 while read line
 do
   ldapid
 done Some file
 

This sounds like a change was made to whatever package ldapid is in.
If ldapid reads from standard input, it will conflict with the use of
stdin by read.

You can work around the problem by doing something like this:

while read line 3
do
  ldapid
done 3 Some file

This way, read isn't using the same stdin file descriptor that ldapid is
(presumably) using.

This is not a bash bug.  It may or may not be an ldapid bug, as I have
no idea what that program does.



Re: ldapscripts unusable from within a 'while read line' loop

2013-08-01 Thread Chris F.A. Johnson

On Thu, 1 Aug 2013, Lakshminarasimhan Srinivasan wrote:
...

Description:
   ldapscripts do not work from inside a while read line loop. The 
exact same scripts were working fine until the last upgrade


Repeat-By:
Prerequisite: ldapscripts installed.
Open a new bash script and type in the following:
-
#!/bin/bash
echo Testing if it works outside of the loop
ldapid
echo Getting into the read line loop
while read line
do
 ldapid
done Some file

The 'ldapid' command, which works outside of the loop, does not work from 
within. This time it throws an error Cannot guess user. Now we check an 
alternative:

Create a new script and type in the following:

#!/bin/bash
echo Testing if it works outside of the loop
ldapid
readarray lines  some file
echo Getting into the for loop
for line in ${lines[@]}
do
 ldapid
done
---
In this case 'ldapid' works both times. In fact, ldapid works in every other 
loop except a 'while read line' and I really do not have any idea why.


  I have no idea what ldapid is or does (I can't find it for my
  system), but perhaps it reads from stdin? If it does, it will be
  reading from the file.

--
   Chris F.A. Johnson, http://cfajohnson.com/
   Author:
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)