Skip to main content
added 24 characters in body
Source Link
slm
  • 379.7k
  • 127
  • 793
  • 897

I have some scripts (that are out of my control) that loads some environment settings to my session. So whenever I want to load I have to execute a series of commands:

export SOME_VAR=/path/to/main/folder
source $SOME_VAR/loading/stuff.sh --quiet
loadApp1
loadApp2
loadApp3
loadApp4

I want to do this with a single command, so I created a function (pretty much the lines above), but it doesn't work.

I think it isit's because the loadApps are aliases, loaded in the stuff.sh so at time bashBash parses my functions it doesn't know the aliases yet.

How could I do this with a single command without lose portabiblitylosing portability? PS

PS: I do not want oto copy the alias to my bashrc$HOME/.bashrc because they can be changechanged elsewhere and I won't see it.

I have some scripts (that are out of my control) that loads some environment settings to my session. So whenever I want to load I have to execute a series of commands:

export SOME_VAR=/path/to/main/folder
source $SOME_VAR/loading/stuff.sh --quiet
loadApp1
loadApp2
loadApp3
loadApp4

I want to this with a single command, so I created a function (pretty much the lines above), but doesn't work.

I think it is because the loadApps are aliases, loaded in the stuff.sh so at time bash parses my functions it doesn't know the aliases yet.

How could I do this with single command without lose portabiblity? PS: I do not want o copy the alias to my bashrc because they can be change elsewhere and I won't see.

I have some scripts (that are out of my control) that loads some environment settings to my session. So whenever I want to load I have to execute a series of commands:

export SOME_VAR=/path/to/main/folder
source $SOME_VAR/loading/stuff.sh --quiet
loadApp1
loadApp2
loadApp3
loadApp4

I want to do this with a single command, so I created a function (pretty much the lines above), but it doesn't work.

I think it's because the loadApps are aliases, loaded in the stuff.sh so at time Bash parses my functions it doesn't know the aliases yet.

How could I do this with a single command without losing portability?

PS: I do not want to copy the alias to my $HOME/.bashrc because they can be changed elsewhere and I won't see it.

Source Link
RSFalcon7
  • 4.5k
  • 6
  • 33
  • 57

How to create a function based on commands not defined yet?

I have some scripts (that are out of my control) that loads some environment settings to my session. So whenever I want to load I have to execute a series of commands:

export SOME_VAR=/path/to/main/folder
source $SOME_VAR/loading/stuff.sh --quiet
loadApp1
loadApp2
loadApp3
loadApp4

I want to this with a single command, so I created a function (pretty much the lines above), but doesn't work.

I think it is because the loadApps are aliases, loaded in the stuff.sh so at time bash parses my functions it doesn't know the aliases yet.

How could I do this with single command without lose portabiblity? PS: I do not want o copy the alias to my bashrc because they can be change elsewhere and I won't see.