I read some following script when looking for script to run Appium with Jenkins
#!/bin/bash --login
killall -9 "iPhone Simulator" &> /dev/null
killall -9 node &> /dev/null
killall -9 instruments &> /dev/null
...
I don't understand why the first line of the script needs to pass a --login option here. I have read the man page but still have some confusions.
What I get from the man page is that passing --login to make the script be called as login shell instead of interactive shell. interactive shell is the shell that users can interact with the shell, like input something with keyboard. But what is login shell? I checked the man page that it said login shell would load ~/.bash_profile, but if open the terminal through Mac OSX's Terminal.app, it also loads the ~/.bash_profile and I am able to interactive with the shell,right? So, the shell I open is both login shell and interactive shell?
The main difference is that a login shell executes your profile when it starts. From the man page:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.
When a login shell exits, bash reads and executes commands from the file ~/.bash_logout, if it exists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With