zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Check existence of a program
Date: Tue, 01 Feb 2011 12:16:56 -0800	[thread overview]
Message-ID: <110201121656.ZM18559@torch.brasslantern.com> (raw)
In-Reply-To: <4D4850F7.6060205@gmail.com>

On Feb 1, 11:59pm, Anonymous bin Ich wrote:
}
} % cat notworking.zsh
} #!/bin/zsh
} set -x
} prog="exiftime"
} path=$(which ${prog})

As has already been pointed out, assigning to $path alters the value of
$PATH, which makes it impossible to find any other executables.

One way to prevent yourself from getting into trouble with this:

    readonly path

Now you can still assign to PATH (and the new value is reflected in
the $path array), but you can't accidentally stomp on it via direct
assignment to path.


  parent reply	other threads:[~2011-02-01 20:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-01 18:29 Anonymous bin Ich
2011-02-01 19:01 ` Julien Nicoulaud
2011-02-01 19:16 ` Benjamin R. Haskell
2011-02-01 19:16 ` Jérémie Roquet
2011-02-01 20:16 ` Bart Schaefer [this message]
2011-02-01 21:39 ` Atom Smasher

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=110201121656.ZM18559@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --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).