[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: is a for .. do list newline sensitive ?
From: |
Lawrence Velázquez |
Subject: |
Re: is a for .. do list newline sensitive ? |
Date: |
Sat, 14 Oct 2023 15:04:20 -0400 |
User-agent: |
Cyrus-JMAP/3.9.0-alpha0-1019-ged83ad8595-fm-20231002.001-ged83ad85 |
On Sat, Oct 14, 2023, at 2:32 PM, Lawrence Velázquez wrote:
> It is not a bug; if present, the word list may not be preceded by
> a line break.
If for some reason you *really* want to keep the variable and word
list on separate lines, you can break before "in". This is portable.
% cat example.sh
for x
in foo bar baz
do
printf %s "$x"
done
echo
% bash ./example.sh
foobarbaz
% dash ./example.sh
foobarbaz
% ksh ./example.sh
foobarbaz
% mksh ./example.sh
foobarbaz
% oksh ./example.sh
foobarbaz
% yash ./example.sh
foobarbaz
% zsh --emulate sh ./example.sh
foobarbaz
--
vq