On 5/11/06, Axel Liljencrantz <[EMAIL PROTECTED]> wrote:
On 5/11/06, Philip Ganchev <[EMAIL PROTECTED]> wrote:
> On 5/10/06, Axel Liljencrantz <[EMAIL PROTECTED]> wrote:
[rearranged]
> > * Rarely what you want. Array separating on newline if often useful,
> > at least in my experience.
>
> Sorry, how does newline come into it?

I was unclear: Command substitution in fish uses newlines as the list
element separator. Bash uses IFS, I belive. Maybe fish should also use
IFS here for consistency?

I still don't get it -- what list?  Do you mean that in Fish, commands
in a command substitution are separated by newlines?  Or do you mean
that in Fish, the output of a command substitution is separated by a
newline?

Is this related to why we get this somewhat surprising behavior?  Why
does this happen?  (There is nothing like this in Bash.)

fish> echo foo(echo 1 2)
foo1 2

fish> echo foo(echo 1\n2)
foo1 foo2

So our main disagreement is whether multiplicative behaviour is
desirable in parameter substitution or not.  How would you rewrite some
of my above examples without multiplicate command substitution?

[rearranged]
# Loop over all users
for i in (cat /etc/passwd); ...; end

Where is the multiplication here?  The loop iterates over lines in
file "/etc/passwd".  This should work as currently.


# Remove a sequence of files
rm img(seq 4 39).jpg

If brace expansion uses whitespace separators,

   rm img{(seq 4 39)}.jpg

Otherwise,

   function comma -d "Convert the array ofarguments into a
comma-separated list useful for brace expansion."
       for i in $argv
           echo -n $i,
       end | sed -r 's/,$//'
   end

   rm img{(seq 4 39)|comma}.jpg


# Print information about select files
ll (find . -type ...)

Where is the multiplication here?  The command substitution outputs a
list of filenames and "ll" uses it as input.  This would work as
currently.

> > [...] I see many
> > problems with the second suggestion:
> >
> > * Posix-incompatible
>
> Sorry, how is it POSIX-incompatible?  Both Sh and Bash work

Bash uses a mix of concatenation and multiplication. I think that it
gets all non-trivial cases wrong, but at least some things are not
concatenated in bash:

for i in $(cat /etc/passwd); do echo $i lalala; done

What is not concatenated here? The loop iterates through each line of
the file and concatenates "lalala" to it.

This is effectively a sting multiplication that can be achieved in the
semantics I proposed as "{(cat /etc/passwd)}lalala" (brace expansion
is space-separated).

Regardless, I don't see how this is an argument against concatenating
adjacent strings in Fish rather than multiplying them.


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to