LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Unsetting Variables & Terminator Placement (https://www.linuxquestions.org/questions/linux-newbie-8/unsetting-variables-and-terminator-placement-4175731543/)

shirase 12-05-2023 12:15 PM

Unsetting Variables & Terminator Placement
 
If I want to temporarily change the IFS like in the example here:
Code:

while IFS='' read -r var ; do cmd ; done ;
Then does it matter which of these are used?
Do they do anything different from each other?
Code:

env -u IFS ; cmd ;
env -u IFS cmd ;
IFS='' ; cmd ;
IFS= ; cmd ;
IFS='' cmd ;
IFS= cmd ;
OLDIFS=IFS ; unset IFS ; cmd ; set IFS=OLDIFS ; unset OLDIFS ;
OLDIFS=IFS ; unset IFS cmd ; set IFS=OLDIFS ; unset OLDIFS ;


pan64 12-05-2023 12:22 PM

yes, they are not all the same, but some of them are identical.
You might want to set -xv before executing these commands to see the differences.
Also you can use different cmd -s to see how they react on those settings (like echo "'$IFS'")


All times are GMT -5. The time now is 09:54 PM.