I have a small function in my
.zshrc. It creates a command to search for and run an executable file, that may or may not exist, in the current directory, or a parent directory somewhere up the current path. I have the logic to find the executable, if it exists, however when I try to run it, I get the following error:
function_name:15: no such file or directory: /Users/username/some/directory/executable_file
Generated by the following code:
if [[ $current_path != / ]] then echo "Using $current_path/executable_file" "$current_path/executable_file $@"
That path is however correct, as copy-and-pasting it, or running the function with sudo, works perfectly. I've tried running the function as current user with
sudo -u in the script, but it still fails.
How can I run the executable script, the same as if the user had typed it in manually, or at least without sudo and a password?