2
I’m trying to create a alias using a shell-script, but at the end of the execution the alias disappears.
#!/bin/sh
echo "Configurando ambiente...";
mkdir -p ~/.dna
alias teste="node $HOME/.dna/start.js"
echo "Exibindo alias criado";
alias teste
The above code creates the alias, because just below the last echo it is displayed, but when trying to execute the command teste
in the terminal it does not find the command.
If I run the excerpt alias teste="node $HOME/.dna/start.js"
directly in the terminal the alias works.
Does anyone know why this occurs and has some contour solution?
Thank you.
Personal because out of scope? It’s a scheduling question.
– Hiago Souza
Probably the alias is not being saved,it exists only in the session that is currently, gives a
export
?– Tuxpilgrim
Not giving export no @Tuxpilgrim .
– Hiago Souza
Take a look at this: https://stackoverflow.com/questions/2197461/how-to-set-an-alias-insida-bash-shell-script-so-that-is-it-visible-from-the-ou
– Tuxpilgrim
Thank you @Tuxpilgrim was exactly what I needed. If you want to translate into the Brazilian community I will mark the answer as correct. Thank you. ;)
– Hiago Souza
Oops, great that worked out! Solved using the
source
or theshopt -s expand_aliases
?– Tuxpilgrim
@Tuxpilgrim using the
source
even.– Hiago Souza
Ready, when you can accept the answer @Hiago!
– Tuxpilgrim