Hello Joaquin,
(I'm talking about PowerShell throughout here because I'm describing
behaviour we don't yet have in Pash but eventually will.)
On 2014-08-18 01:15, Joaquin Menchaca wrote:
> My Shebang line is the following:
>
> *#!/usr/bin/env pash*
Technically you would need to include the -File parameter here. This is
because PowerShell otherwise interprets its argument as a command to
run. This *does* work for invoking a script *sometimes*. But there is a
subtle difference.
-File takes the next argument and knows it has to be a script file, and
if it's not qualified with an absolute path the search will be from the
current working directory. This happens in the current working directory
given by the system.
If you have a profile that sets a different directory (e.g. my own
profile creates a new drive Home: that's mapped to ~ and does a
Set-Location there), then the method *without* -File would fail, because
PowerShell then starts, loads its profile and then tries to execute the
command. Worse, it will run a completely different script if you happen
to have one with the same name in the directory it starts up with.
My own scripts usually run with the following invocation:
powershell -noprofile -file ...
This allows me to write scripts that stay in the current directory and
do things there (as I said, my profile changes it) and also forces me to
write scripts that run everywhere by using only default aliases. For me
the profile is more something that makes interactive use nicer, not a
base for scripts.
I don't know how to pass additional parameters in a shebang line as the
one you have there currently, though. I have no idea what env does with
them if you just stick them at the end.
Regards,
Johannes