From: "Daniel Shahaf" <d.s@daniel.shahaf.name>
To: zsh-users@zsh.org
Subject: Re: using zshz to select target directory
Date: Thu, 22 Sep 2022 07:25:04 +0000 [thread overview]
Message-ID: <ca67b3fe-44d3-473c-84f1-1a473c4014ff@www.fastmail.com> (raw)
In-Reply-To: <597b635d-4f36-2d4e-75bf-006f226b1e28@rayninfo.co.uk>
zzapper wrote on Tue, 20 Sep 2022 07:55 +00:00:
> sz () {
> alias z='zshz 2>&1'
> if (( $# != 2 ))
> then
> echo 'Usage: Enter file to copy & destination directory string
> for z'
> echo 'e.g: sz file.txt project2'
> return 1
> fi
> f=$1
> zshz $2 2>&1
> cp -ip ~-/$f .
> }
Instead of changing global state (cwd), it would be more idiomatic to
call a function that returns a string via $REPLY, and then «cp -ip --
./$f $REPLY». Or just stick the last two commands in a subshell, so the
outer shell's cwd doesn't change.
The alias definition is also a form of changing global state.
Also, usage messages should start with the name of the command (or in
this case, function).
next prev parent reply other threads:[~2022-09-22 7:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 7:55 zzapper
2022-09-22 7:25 ` Daniel Shahaf [this message]
2022-09-22 8:15 ` david rayner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ca67b3fe-44d3-473c-84f1-1a473c4014ff@www.fastmail.com \
--to=d.s@daniel.shahaf.name \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).