Be worried.

I am looking for a way to register an alias in a shell script that is intended for temporary use.

Why do I want this

A project involving multiple people, in a project file
It is assumed that there are many opportunities to issue a specific command.

For example... (Here, ex-command is used as an example)

When using it yourselfalias ex-command=''It is enough if you register
When asking for confirmation work, you can't say "type ex-command."

However, I was wondering if the processing contents specific to the project should be registered in .bashrc...

From the above circumstances, if you have a "shell script that temporarily registers ex-command because it is only necessary for confirmation work",
When you use ex-command, you will be told "Please execute ex-command after executing this script".
I thought it would be easier to make a request.

Usage environment

Windows10 home
GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)

What I actually tried.

I created and confirmed the following code.

alias ex-command='echo hello!'

Type in when you temporarily registeralias ex-command='echo hello!'To
It will be the one you typed in the shell script as it is.

Since my environment was bash, shebang is /bin/bash.

I ran chmod +x on the resulting file and ran it.
The alias was not registered even if I typed ex-command.

What i looked up
  • You can temporarily register alias by typing command
  • To register the alias permanently, describe it in .bashrc (for bash)
  • To run alias with a shell script,shopt -s expand_aliasesNeed to be set.
    Regarding ↑, I feel a little different because it is "when I want to use it in a shell script".

Thank you for watching till the end.
If necessary information is missing, we will add it at any time, so thank you.