I want to have a script to call with params which adds some aliases to my current shell. The aliases have to be builded in respect to the calling parameters and the current directory from where I start it. If possible I would like to NOT have to source the script, just run it like any other script.
This is what I have done until now:
I wrote a small shell script to generate some aliases, like
echo 'alias foo="$1"'
and save it as file "myscript" with +x rights. Then I execute it via console to set the alias
$(myscipt hello)
that works fine
When I change my shell script like
echo 'alias foo="bar $1 -param"'
and execute again like above, the result is
bash: alias hello" not found
bash: alias -param" not found
???. I escaped already the blanks between bar and -param but can't get it work.
when I execute
source <(myscript hello)
everything is fine like expected (That is my solution by now but not sure if it is the best).
Some ideas how to get a better solution?
Comments
Post a Comment