Created a file with the following content:
#!/bin/bash alias some='echo 2' I gave him the right to execute and nothing happens when the script is executed (no alias is created). What am I doing wrong? Bash version 4.3.46
Created a file with the following content:
#!/bin/bash alias some='echo 2' I gave him the right to execute and nothing happens when the script is executed (no alias is created). What am I doing wrong? Bash version 4.3.46
pseudo-variable, variables, functions — these are all properties of the shell process. they are inherited by the child processes, but the child process cannot affect the properties of the parent process.
when you “run” a script, a new (child) instance of the shell process is created, and after it completes, all its aliases, variables and functions are irretrievably lost (well, not saved, for example, to a file).
to ensure that commands from the script are executed within the current shell process (without creating a child process), you can use the built-in source command (or its synonym - . ):
$ source скрипт or
$ . скрипт in general, the definitions of all aliases, variables, and functions that should be available in each interactive shell session are usually placed in the ~/.bashrc , which is “invoked” with the source ~/.bashrc command at the end of the launch of a new interactive session.
Source: https://ru.stackoverflow.com/questions/626217/
All Articles
source a.sh- Alexey Ten.bashrc/.bash_aliases- Alexey Ten