Shebang and self-executing

80 views
Skip to first unread message

Joaquin Menchaca

unread,
Dec 27, 2014, 9:48:23 PM12/27/14
to pash-p...@googlegroups.com
I did the following:

git clone https://github.com/Pash-Project/Pash.git
cd Pash
xbuild
echo 'mono ~/Pash/Source/PashConsole/bin/Debug/Pash.exe "$@"' > /usr/local/bin/pash
chmod +x /usr/local/bin/pash

Then in my script, such as this one I have:

#!/usr/bin/env pash
Write-Host Hello 

Running this script causes:

$./hello.ps1
Command '/a00.output.ps1' not found.
  +CategoryInfo: ObjectNotFound, Reason: ParentContainsErrorRecordException
  +FullyQualifiedErrorId: CommandNotFoundException

I can successfully run this scripting doing

$ pash hello.ps1

Any recommended way of supporting she-bang?

Stefan Burnicki

unread,
Dec 30, 2014, 10:05:48 AM12/30/14
to pash-p...@googlegroups.com
Hi,

yes this is a Pash issue. It's because shebang passes the filename as a first argument and Pash interprets arguments as commands to be executed.
The command to execute a script needs a '&' or '.' operator. (There is also another issue where relative paths are interpreted as ". /foo" instead of "./foo")

As a workaround you could somehow prepend a "& " to all arguments passed to /usr/local/bin/pash. However, I'm afraid this workaround will run you into more issues (e.g. script paths with whitespaces).

Long story short, we need to implement some Pash argument to explicitly execute scripts. I will put this on my list and implement it in January.
Reply all
Reply to author
Forward
0 new messages