I'm trying to alias my php command by executing it with an argument depending on if a file with my remote host IP is existant, without any additional argument otherwise.
I got it working with this version
#!/bin/bash
alias php="[ -f path/to/hostip ] && php -dxdebug.remote_host=\"$( < path/to/hostip )\" || php
Two issues
- it's too long (luxury problem)
- when calling
php path/to/any/script
my further arguments aren't passed to the php call
I tried a function, which solves issue #2
#!/bin/bash
function phpx {
if [ -f path/to/hostip ]; then
php -dxdebug.remote_host="$( < path/to/hostip )" "$@"
else
php "$@"
fi
}
But I still have issues
- it's much more longer (luxury problem)
- I can't use
php
as the alias for the function name
What I'm looking for is an alias for php
like
alias php='php ( condition | true > pass file content as argument | false > pass nothing )'
And I want to be able to pass my further arguments to the alias.
command php
instead of purephp
in your script.