help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] flummoxed


From: Federico Prades Illanes
Subject: Re: [Help-bash] flummoxed
Date: Thu, 9 Oct 2014 14:52:12 +0200

I'm just guessing here, is is possible that your script is using the cd
built-in. The default behaviour is to change the directory back to $HOME,
so you might be doing this accidentally, for example as cd $NOTSET.

It will also help to send the contents of your 'If' script.

On 9 October 2014 11:14, Brian Tew <address@hidden> wrote:

> Brian Tew
> address@hidden
>
> Ok I have this tiny bash script callef lf to list files only (no sub
> directories).
> Problem is that it lists the files in my home dir no matter what dir I am
> in.
> I want it to list the files in the current directory.
> The lf command is in /usr/local/bin, and there are no aliases or functions
> with that  name.
> I also put an exact copy of lf called lfx in /usr/local/bin except it has
> 'set -x' in it.
> Here it the output of my tests below.
> I am flummoxed.
> Thanks for any help.
>
> Script started on Mon 06 Oct 2014 09:39:44 AM CDT
> ~$ls
> home1
> home2
> tmp
> ttt
> typescript
> ~$lf
> home1
> home2
> typescript
> ~$cd tmp
> tmp$ls
> tmp1
> tmp2
> tmp$lf
> home1
> home2
> typescript
> tmp$cd
> ~$ls
> home1
> home2
> tmp
> ttt
> typescript
> ~$lf
> home1
> home2
> typescript
> ~$cd tmp
> tmp$ls
> tmp1
> tmp2
> tmp$lf
> home1
> home2
> typescript
> tmp$which lf
> /usr/local/bin/lf
> tmp$cd /usr/local/bin
> bin$cat lf
> for f in *; do [[ -d "$f" ]] || echo "$f"; done
> bin$cat lfx
> set -x
> for f in *; do [[ -d "$f" ]] || echo "$f"; done
> bin$cd
> ~$ls
> home1
> home2
> tmp
> ttt
> typescript
> ~$lfx
> ++ for f in '*'
> ++ [[ -d home1 ]]
> ++ echo home1
> home1
> ++ for f in '*'
> ++ [[ -d home2 ]]
> ++ echo home2
> home2
> ++ for f in '*'
> ++ [[ -d tmp ]]
> ++ for f in '*'
> ++ [[ -d ttt ]]
> ++ for f in '*'
> ++ [[ -d typescript ]]
> ++ echo typescript
> typescript
> ~$cd tmp
> tmp$ls
> tmp1
> tmp2
> tmp$lfx
> ++ for f in '*'
> ++ [[ -d home1 ]]
> ++ echo home1
> home1
> ++ for f in '*'
> ++ [[ -d home2 ]]
> ++ echo home2
> home2
> ++ for f in '*'
> ++ [[ -d tmp ]]
> ++ for f in '*'
> ++ [[ -d ttt ]]
> ++ for f in '*'
> ++ [[ -d typescript ]]
> ++ echo typescript
> typescript
> tmp$uname -a
> Linux Laggy 3.11.0-26-generic #45-Ubuntu SMP Tue Jul 15 04:02:06 UTC 2014
> x86_64 x86_64 x86_64 GNU/Linux
> tmp$bash --version
> GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
> Copyright (C) 2013 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <
> http://gnu.org/licenses/gpl.html>
>
> This is free software; you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> tmp$exit
>
> Script done on Mon 06 Oct 2014 09:46:21 AM CDT
>
>


reply via email to

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