* [Fwd: Parameter Expansion questions]
@ 1998-08-17 15:17 David R. Favor
1998-08-17 15:44 ` Bruce Stephens
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: David R. Favor @ 1998-08-17 15:17 UTC (permalink / raw)
To: Zsh List
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: Type: message/rfc822, Size: 1577 bytes --]
From: "David R. Favor" <dfavor@austin.ibm.com>
To: Zefram <zefram@tao.co.uk>
Subject: Re: Parameter Expansion questions
Date: Mon, 17 Aug 1998 10:16:58 -0500
Message-ID: <35D8496A.B936DCDF@austin.ibm.com>
> > splitpath=${buf:gs/:/ /}
>
> That's doing a substitution, rather than field splitting. Since the
> effect you're asking for is actually a substitution, rather than field
> splitting (since you're just joining up the fields again anyway), this
> is logically the correct thing to do.
>
> OTOH, I suspect that you *really* want to be using an array parameter.
> $path is an array version of $PATH, so you don't even need to do the
> splitting manually in that case.
Here's a larger fragment of the function I'm using, that is a wrapper
around vi to check several directories for a file to edit. What is the
recommended way to accomplish this in zsh, hopefully while retaining
ksh compatibility also? I would like to get rid of the $shell_type
nonsense and the ${=editpath} syntax in the loop.
Thanks.
_______
# paths to search
editpath=${EDITPATH:-"$PATH:$CDPATH"}
IFS=:
if [ $shell_type = 'zsh' ] ; then <<< $shell_type
editpath=${editpath:gs/:/ /}
else
editpath=$editpath
fi
IFS="$BACKUP_IFS"
for name in $* ; do
for dir in ${=editpath} ; do <<< ${=editpath}
# find/edit the file
done
done
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Fwd: Parameter Expansion questions]
1998-08-17 15:17 [Fwd: Parameter Expansion questions] David R. Favor
@ 1998-08-17 15:44 ` Bruce Stephens
1998-08-17 15:52 ` vi wrapper -> vim + "set path" Sven Guckes
1998-08-17 16:08 ` [Fwd: Parameter Expansion questions] Peter Stephenson
2 siblings, 0 replies; 4+ messages in thread
From: Bruce Stephens @ 1998-08-17 15:44 UTC (permalink / raw)
To: David R. Favor; +Cc: Zsh List
"David R. Favor" <dfavor@austin.ibm.com> writes:
> # paths to search
> editpath=${EDITPATH:-"$PATH:$CDPATH"}
>
> IFS=:
>
> if [ $shell_type = 'zsh' ] ; then <<< $shell_type
> editpath=${editpath:gs/:/ /}
> else
> editpath=$editpath
> fi
>
> IFS="$BACKUP_IFS"
>
> for name in $* ; do
>
> for dir in ${=editpath} ; do <<< ${=editpath}
>
> # find/edit the file
>
> done
>
> done
How about replacing
editpath=${editpath:gs/:/ /}
with
editpath=(${=editpath})
i.e., you create editpath as an array, which allows the loop to be the
same in ksh and zsh:
for dir in $editpath; do
That doesn't remove the need for the shell choice earlier, however.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: vi wrapper -> vim + "set path"
1998-08-17 15:17 [Fwd: Parameter Expansion questions] David R. Favor
1998-08-17 15:44 ` Bruce Stephens
@ 1998-08-17 15:52 ` Sven Guckes
1998-08-17 16:08 ` [Fwd: Parameter Expansion questions] Peter Stephenson
2 siblings, 0 replies; 4+ messages in thread
From: Sven Guckes @ 1998-08-17 15:52 UTC (permalink / raw)
To: Zsh List; +Cc: David R . Favor
Quoting David R. Favor (dfavor@austin.ibm.com):
> .. wrapper around vi to check several directories for a file to edit.
> What is the recommended way to accomplish this in zsh?
vim -c "se cp path=.,,dir1,dir2,...,dirN"
Sven ;-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Fwd: Parameter Expansion questions]
1998-08-17 15:17 [Fwd: Parameter Expansion questions] David R. Favor
1998-08-17 15:44 ` Bruce Stephens
1998-08-17 15:52 ` vi wrapper -> vim + "set path" Sven Guckes
@ 1998-08-17 16:08 ` Peter Stephenson
2 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 1998-08-17 16:08 UTC (permalink / raw)
To: Zsh users list, David R. Favor
"David R. Favor" wrote:
> Here's a larger fragment of the function I'm using, that is a wrapper
> around vi to check several directories for a file to edit. What is the
> recommended way to accomplish this in zsh, hopefully while retaining
> ksh compatibility also? I would like to get rid of the $shell_type
> nonsense and the ${=editpath} syntax in the loop.
If ksh compatibility is your main aim, the recommended way is to put
[[ -n $ZSH_VERSION ]] && emulate ksh
at the top and write it in standard ksh. This is supposed to remove all
your problems. If it still doesn't work, then we want to know about it.
This sets all sorts of options you probably don't even want to know
about if you just want ksh compatibility. (By the way, I think you had
option setting wrong back there somewhere: it's `set -o OPTION' or
`setopt OPTION', not `export OPTION', which is why some of your attempts
didn't work.)
--
Peter Stephenson <pws@ifh.de> Tel: +39 50 844536
WWW: http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1998-08-17 16:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-08-17 15:17 [Fwd: Parameter Expansion questions] David R. Favor
1998-08-17 15:44 ` Bruce Stephens
1998-08-17 15:52 ` vi wrapper -> vim + "set path" Sven Guckes
1998-08-17 16:08 ` [Fwd: Parameter Expansion questions] Peter Stephenson
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).