Skip to main content
Added some context. Dressed the naked link. Fixed the question formation - missing auxiliary (or helping) verb - see e.g. <https://www.youtube.com/watch?v=t4yWEt0OSpg&t=1m49s> (see also <https://www.youtube.com/watch?v=kS5NfSzXfrI> (QUASM)) - alternatively, drop the question mark (title only).
Source Link

Consider this. IFS is set only in the execution of read.

IFS='' read -r REPLY

However, if I do similar with . (source), the variable will be assigned and changed even after the execution of the line of code.

PATH="/new_path:${PATH}" . script.sh
echo "$PATH"         # valueValue changed

Why would this happen? I thought ., as well as Bash's source, is a command just like read or echo. Is there any documentation, e.g., https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_142.14. Special Built-In Utilities, mentioning about this behaviour?

How can I temporarily set $PATH and . (source) a file, in the POSIX compliant way?

Consider this. IFS is set only in the execution of read.

IFS='' read -r REPLY

However, if I do similar with . (source), the variable will be assigned and changed even after the execution of the line of code.

PATH="/new_path:${PATH}" . script.sh
echo "$PATH"         # value changed

Why would this happen? I thought ., as well as Bash's source, is a command just like read or echo. Is there any documentation, e.g., https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14, mentioning about this behaviour?

How can I temporarily set $PATH and . (source) a file, in the POSIX compliant way?

Consider this. IFS is set only in the execution of read.

IFS='' read -r REPLY

However, if I do similar with . (source), the variable will be assigned and changed even after the execution of the line of code.

PATH="/new_path:${PATH}" . script.sh
echo "$PATH"         # Value changed

Why would this happen? I thought ., as well as Bash's source, is a command just like read or echo. Is there any documentation, e.g., 2.14. Special Built-In Utilities, mentioning this behaviour?

How can I temporarily set $PATH and . (source) a file, in the POSIX compliant way?

Added some context. Fixed the question formation - missing auxiliary (or helping) verb - see e.g. <https://www.youtube.com/watch?v=t4yWEt0OSpg&t=1m49s> (see also <https://www.youtube.com/watch?v=kS5NfSzXfrI> (QUASM)) - alternatively, drop the question mark (title only).
Source Link

How tocan I temporarily set $PATH and . (source) a file?

Consider this. IFS is set only in the execution of read.

IFS='' read -r REPLY

However, if I do similar with .. (sourcesource), the variable will be assigned and changed even after the execution of the line of code.

PATH="/new_path:${PATH}" . script.sh
echo "$PATH"         # value changed

Why would this happen? I thought ., as well as the bash'sBash's source, is a command just like read or echo. AnyIs there any documentation  , e.g., https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14  , mentioning about this behaviour?

How tocan I temporarily set $PATH and .. (source) a file, in the POSIX compliant way?

How to temporarily set $PATH and . (source) a file?

Consider this. IFS is set only in the execution of read.

IFS='' read -r REPLY

However, if I do similar with . (source), the variable will be assigned and changed even after the execution of the line of code.

PATH="/new_path:${PATH}" . script.sh
echo "$PATH"         # value changed

Why would this happen? I thought ., as well as the bash's source, is a command just like read or echo. Any documentation  , e.g. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14  , mentioning about this behaviour?

How to temporarily set $PATH and . (source) a file, in the POSIX compliant way?

How can I temporarily set $PATH and . (source) a file?

Consider this. IFS is set only in the execution of read.

IFS='' read -r REPLY

However, if I do similar with . (source), the variable will be assigned and changed even after the execution of the line of code.

PATH="/new_path:${PATH}" . script.sh
echo "$PATH"         # value changed

Why would this happen? I thought ., as well as Bash's source, is a command just like read or echo. Is there any documentation, e.g., https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14, mentioning about this behaviour?

How can I temporarily set $PATH and . (source) a file, in the POSIX compliant way?

Became Hot Network Question
Source Link
midnite
  • 613
  • 1
  • 7
  • 19

How to temporarily set $PATH and . (source) a file?

Consider this. IFS is set only in the execution of read.

IFS='' read -r REPLY

However, if I do similar with . (source), the variable will be assigned and changed even after the execution of the line of code.

PATH="/new_path:${PATH}" . script.sh
echo "$PATH"         # value changed

Why would this happen? I thought ., as well as the bash's source, is a command just like read or echo. Any documentation , e.g. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14 , mentioning about this behaviour?

How to temporarily set $PATH and . (source) a file, in the POSIX compliant way?