* Arrays with each item on one line
@ 2012-01-31 23:55 TJ Luoma
2012-02-01 0:48 ` Benjamin R. Haskell
0 siblings, 1 reply; 5+ messages in thread
From: TJ Luoma @ 2012-01-31 23:55 UTC (permalink / raw)
To: zsh-users
I don't understand arrays very well and am trying to learn.
I keep trying to do things like this:
FILES=("$HOME/Library/Application Support/Keyboard Maestro"
"$HOME/Library/Preferences/com.stairways.keyboardmaestro.editor.plist"
"$HOME/Library/Preferences/com.stairways.keyboardmaestro.engine.plist"
"$HOME/Library/Preferences/com.stairways.keyboardmaestro.plist")
for F in $FILES
do
command ls -ld "$F"
done
but instead of $F being each line for 4 iterations of the loop, I get
all 4 lines x 4 times.
I thought that the solution was changing IFS, so I tried:
IFS='
'
and
IFS=$'\n'
but that doesn't seem to change anything.
Can someone tell me what I'm missing?
Thanks
TjL
Zsh version 4.3.11 on Mac OS X/10.7
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Arrays with each item on one line
2012-01-31 23:55 Arrays with each item on one line TJ Luoma
@ 2012-02-01 0:48 ` Benjamin R. Haskell
2012-02-01 2:28 ` TJ Luoma
0 siblings, 1 reply; 5+ messages in thread
From: Benjamin R. Haskell @ 2012-02-01 0:48 UTC (permalink / raw)
To: TJ Luoma; +Cc: zsh-users
On Tue, 31 Jan 2012, TJ Luoma wrote:
> I don't understand arrays very well and am trying to learn.
>
> I keep trying to do things like this:
>
> FILES=("$HOME/Library/Application Support/Keyboard Maestro"
> "$HOME/Library/Preferences/com.stairways.keyboardmaestro.editor.plist"
> "$HOME/Library/Preferences/com.stairways.keyboardmaestro.engine.plist"
> "$HOME/Library/Preferences/com.stairways.keyboardmaestro.plist")
>
> for F in $FILES
> do
>
> command ls -ld "$F"
>
> done
>
> but instead of $F being each line for 4 iterations of the loop, I get
> all 4 lines x 4 times.
>
> [...]
>
> Can someone tell me what I'm missing?
>
> [...]
>
> Zsh version 4.3.11 on Mac OS X/10.7
Your example works fine for me using Zsh version 4.3.11 under OSX 10.7.
What do you get from running 'setopt'? I get:
autocd
noautomenu
autopushd
nocheckjobs
cshjunkiehistory
extendedglob
extendedhistory
noglobalrcs
globdots
histignoredups
histignorespace
histnostore
histsubstpattern
nohup
incappendhistory
interactive
login
magicequalsubst
monitor
nonotify
promptsubst
pushdsilent
shinstdin
zle
I don't think any of those should affect how arrays are interpreted.
So, you can probably ignore any of the ones in that list that appear in
yours, too.
--
Best,
Ben
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Arrays with each item on one line
2012-02-01 0:48 ` Benjamin R. Haskell
@ 2012-02-01 2:28 ` TJ Luoma
2012-02-01 2:42 ` Benjamin R. Haskell
0 siblings, 1 reply; 5+ messages in thread
From: TJ Luoma @ 2012-02-01 2:28 UTC (permalink / raw)
To: Benjamin R. Haskell; +Cc: zsh-users
On Tue, Jan 31, 2012 at 7:48 PM, Benjamin R. Haskell <zsh@benizi.com> wrote:
> What do you get from running 'setopt'? I get:
autocd
extendedglob
nofunctionargzero
interactive
listpacked
login
promptsubst
pushdignoredups
shinstdin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Arrays with each item on one line
2012-02-01 2:28 ` TJ Luoma
@ 2012-02-01 2:42 ` Benjamin R. Haskell
2012-02-01 2:59 ` TJ Luoma
0 siblings, 1 reply; 5+ messages in thread
From: Benjamin R. Haskell @ 2012-02-01 2:42 UTC (permalink / raw)
To: TJ Luoma; +Cc: zsh-users
On Tue, 31 Jan 2012, TJ Luoma wrote:
> On Tue, Jan 31, 2012 at 7:48 PM, Benjamin R. Haskell <zsh@benizi.com> wrote:
>> What do you get from running 'setopt'? I get:
>
> autocd
> extendedglob
> nofunctionargzero
> interactive
> listpacked
> login
> promptsubst
> pushdignoredups
> shinstdin
Even with that set of options, I don't get the behavior you described.
Maybe I'm misunderstanding your explanation? It seems more likely that
you're not posting the actual code you're using. Running the code you posted:
FILES=("$HOME/Library/Application Support/Keyboard Maestro"
"$HOME/Library/Preferences/com.stairways.keyboardmaestro.editor.plist"
"$HOME/Library/Preferences/com.stairways.keyboardmaestro.engine.plist"
"$HOME/Library/Preferences/com.stairways.keyboardmaestro.plist")
for F in $FILES
do
command ls -ld "$F"
done
on the OSX machine I have access to, I get (as expected, since the files
don't exist):
$
ls: /Users/bhaskell/Library/Application Support/Keyboard Maestro: No such file or directory
ls: /Users/bhaskell/Library/Preferences/com.stairways.keyboardmaestro.editor.plist: No such file or directory
ls: /Users/bhaskell/Library/Preferences/com.stairways.keyboardmaestro.engine.plist: No such file or directory
ls: /Users/bhaskell/Library/Preferences/com.stairways.keyboardmaestro.plist: No such file or directory
$
So, the FILES array is only looped over once.
--
Best,
Ben
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Arrays with each item on one line
2012-02-01 2:42 ` Benjamin R. Haskell
@ 2012-02-01 2:59 ` TJ Luoma
0 siblings, 0 replies; 5+ messages in thread
From: TJ Luoma @ 2012-02-01 2:59 UTC (permalink / raw)
To: Benjamin R. Haskell; +Cc: zsh-users
ARGH.
Sorry.
PEBKAC.
(I was using $FILES instead of $F inside the loop.)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-02-01 3:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-31 23:55 Arrays with each item on one line TJ Luoma
2012-02-01 0:48 ` Benjamin R. Haskell
2012-02-01 2:28 ` TJ Luoma
2012-02-01 2:42 ` Benjamin R. Haskell
2012-02-01 2:59 ` TJ Luoma
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).