Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Vared with newlines between array elements



I just realised this trivial function is the answer to all my problems
with editing path and similar array variables with vared --- it puts
each element on a new line, so it's much easier to manipulate elements
separately.

To get filename completion to work properly, it should only require
backslashes before newlines and not other whitespace, nor anything else.
In other words, you get `/e/Program\ Files' from completion, but you
need `/e/Program Files' because vared preserves the backslash.
This could be fixed up if vared always stripped backslashes, which is
more symmetric since it always doubles existing backslashes (i.e. if you
had `/e/Program\ Files' to begin with it would have been quoted as
`/e/Program\\ Files' for editing.  However, the function is buried
inside the shell array splitting functions, so it's not entirely trivial
to fix without knock-on effects.

# Use vared with array elements joined by newlines.
# This makes reordering or removal of elements much simpler.
#
# With this function whitespace other than newlines in array elements
# should not be quoted by a backslash; this needs special completion
# handling (not currently provided).

local IFS='
'

vared "$@"
# End

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author