Sean Mackesey
Sean Mackesey

Reputation: 10939

Relative path to executable is not resolved in zsh script

I have a personal scripts folder: ~/google_drive/code/scripts. This folder is on my $path. $path is set in ~/.zshenv and not changed anywhere else (I've disabled OS X path_helper and I don't touch $path in any other zsh startup file). In this scripts folder, there is a subdirectory called alfred_workflows. From the command line, from any location I am able to run scripts in this folder with relative paths. This is expected:

$ alfred_workflows/test.sh
#=> test successful

But in a script, this does not work. It generates an error:

$ zsh -c "alfred_workflows/test.sh"
#=> zsh:1: no such file or directory: alfred_workflows/test.sh

Once again, the scripts directory that contains alfred_workflows is on $path, which is set in ~/.zshenv, and I am able to run executables that reside in the top level of this directory from a script. The issue only seems to be when I try to go through a subdirectory. What might be the problem?

Upvotes: 1

Views: 1057

Answers (1)

qqx
qqx

Reputation: 19475

Searching of the $path is only done for names containing a slash if the path_dirs option is set. Apparently that's set in your interactive shell, but isn't set in the process that's executing the script.

Upvotes: 4

Related Questions