* script help
@ 2012-12-08 11:15 shawn wilson
2012-12-08 15:09 ` Aaron Schrab
0 siblings, 1 reply; 4+ messages in thread
From: shawn wilson @ 2012-12-08 11:15 UTC (permalink / raw)
To: Zsh Users
this is in my .zshrc file and it fails to execute $cmd with:
vim:45: no such file or directory: /usr/local/bin/vim --servername SWILSON
######## zshrc part:
# make vim use or initialize a session with a new tab unless...
vim () {
local cmd
local servername
local remote
local username=$(echo $USER | tr "[:lower:]" "[:upper:]")
local opt_ex="^-"
while [ $# -gt 0 ] ; do
case "$1" in
--servername)
if [[ $1 =~ $opt_ex ]] ; then
echo "Servername option without a parameter. Doing nothing."
return
else
servername="$2"
return
fi
;;
--remote*)
if [ -z $remote ] ; then
remote=$1
else
# I'll deal with this properly if it is reasonable
to take multiple --remote* things
echo "Should not call two remote options at once.
Doing nothing."
return
fi
;;
*)
misc="$misc $1"
;;
esac
shift
done
cmd="/usr/local/bin/vim"
if [ ! -z $servername ] ; then
cmd="$cmd --servername $servername"
else
cmd="$cmd --servername $username"
fi
if [ -z $misc ] && [ -z $remote ] ; then
$cmd
return
fi
if [ ! -z $remote ] ; then
cmd="$cmd $remote $misc"
else
cmd="$cmd --remote-tab $misc"
fi
$cmd
return
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: script help
2012-12-08 11:15 script help shawn wilson
@ 2012-12-08 15:09 ` Aaron Schrab
2012-12-08 15:43 ` shawn wilson
0 siblings, 1 reply; 4+ messages in thread
From: Aaron Schrab @ 2012-12-08 15:09 UTC (permalink / raw)
To: shawn wilson; +Cc: Zsh Users
At 06:15 -0500 08 Dec 2012, shawn wilson <ag4ve.us@gmail.com> wrote:
>this is in my .zshrc file and it fails to execute $cmd with:
>vim:45: no such file or directory: /usr/local/bin/vim --servername
>SWILSON
Normally zsh doesn't split the result of variable expansion into
separate words. You can enable that for your function by adding the
following line to it:
setopt local_options sh_word_split
Enabling the local_options option will cause other options set within
the function to be returned to their original state when the function
returns. The sh_word_split option will cause the results of expanding
your $cmd variable to be split into words before evaluating that line,
allowing it to be used as you intended.
Another option would be to use ${=cmd} in place of just $cmd when you
attempt to run that command. That will cause word splitting to be done
in that case only.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: script help
2012-12-08 15:09 ` Aaron Schrab
@ 2012-12-08 15:43 ` shawn wilson
2012-12-08 17:07 ` Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: shawn wilson @ 2012-12-08 15:43 UTC (permalink / raw)
To: Aaron Schrab, Zsh Users
First thanks, I used ${=cmd} and it worked.
On Sat, Dec 8, 2012 at 10:09 AM, Aaron Schrab <aaron@schrab.com> wrote:
> At 06:15 -0500 08 Dec 2012, shawn wilson <ag4ve.us@gmail.com> wrote:
>>
>> this is in my .zshrc file and it fails to execute $cmd with:
>> vim:45: no such file or directory: /usr/local/bin/vim --servername SWILSON
>
>
> Normally zsh doesn't split the result of variable expansion into separate
> words.
I don't think I understand this. how is a string different from zsh
splitting a variable up (I'm guessing an array based on ${=cmd})? And
I'm guessing this is different from how bash handles this?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-12-08 17:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-08 11:15 script help shawn wilson
2012-12-08 15:09 ` Aaron Schrab
2012-12-08 15:43 ` shawn wilson
2012-12-08 17:07 ` Bart Schaefer
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).