help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] flummoxed


From: Greg Wooledge
Subject: Re: [Help-bash] flummoxed
Date: Thu, 9 Oct 2014 08:56:10 -0400
User-agent: Mutt/1.4.2.3i

On Thu, Oct 09, 2014 at 04:14:42AM -0500, Brian Tew wrote:
> Ok I have this tiny bash script callef lf to list files only (no sub 
> directories).

> bin$cat lf
> for f in *; do [[ -d "$f" ]] || echo "$f"; done

Missing the shebang.

> I also put an exact copy of lf called lfx in /usr/local/bin except it has 
> 'set -x' in it.

> bin$cat lfx
> set -x
> for f in *; do [[ -d "$f" ]] || echo "$f"; done

Also missing the shebang.

> Problem is that it lists the files in my home dir no matter what dir I am in.

> ~$cd tmp
> tmp$ls
> tmp1
> tmp2
> tmp$lf
> home1
> home2
> typescript

Speculation: since there is no shebang, the script is executed by your
interactive shell (presumably bash), instead of by the shell listed in
the shebang.  And you have the BASH_ENV variable set, and you have a
"cd" command in the file that it names.

(If your interactive shell is ksh, then the same thing applies but with
the ENV variable instead of BASH_ENV.)

If that turns out not to be the cause, then we'll need more information.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]