From a Bash shell, which of the following commands directly execute the instructions from the file /usr/local/bin/runme.sh without starting a subshell? (Choose two.)
Create a script that outputs the shell level environmental variable using "echo $SHLVL". When you execute this script using source or dot (.) it will display 1 showing that the script was executed in the current shell. When you execute the script using full path it will show 2, showing that the script was executed in a subshell.
Maybe something changed here. Correct answer is A and B tried on arch linux. running bash script using absolute path does not creates subshell (does not increments $SHLVL variable)
When a script is run using source it runs within the existing shell, any variables created or modified by the script will remain available after the script completes.
source is a synonym for dot/period '.' in bash.
Be careful!
./ and source are not quite the same.
./script runs the script as an executable file, launching a new shell to run it
https://ss64.com/bash/source.html
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Negator
Highly Voted 3 years, 11 months agoCuriousLinuxCat
Highly Voted 3 years, 7 months agoAleksandre
Most Recent 7 months, 4 weeks agoNinymo
11 months, 3 weeks agoMchoeti
1 year, 11 months agojsteven845
4 years agomriron
4 years, 2 months agoMIU
4 years, 3 months agoilputto
4 years, 4 months agoVendo
4 years, 7 months agosnota45
4 years, 7 months agoVano1
4 years, 7 months agoVano1
4 years, 7 months agoVano1
4 years, 7 months agodeewetdvjbmnjkjytfdszxc
4 years, 7 months ago