View Issue Details

IDProjectCategoryView StatusLast Update
00012581003.1(2016/18)/Issue7+TC2Shell and Utilitiespublic2024-06-11 09:08
Reporterstephane Assigned To 
PrioritynormalSeverityObjectionTypeError
Status ClosedResolutionAccepted As Marked 
NameStephane Chazelas
Organization
User Reference
Sectionexport utility
Page Number2402 (in 2018 edition)
Line Number76898 (in 2018 edition)
Interp Status---
Final Accepted TextSee 0001258:0004488
Summary0001258: incorrect usage of "." utility in "export" example.
DescriptionThe "EXAMPLES" section of the "export" utility has:

export −p > temp-file
unset a lot of variables
... processing
. temp-file


In POSIX compliant shells, "." looks up files in $PATH, not the current directory when the file argument doesn't contain any slash, so it should be: ". ./temp-file".

It may also be worth mentioning that it may not work if the "unset a lot of variables" part unsets LC_CTYPE, LANG or LC_ALL variables (or the "processing" part sets any of them) as the "." utility could then be run in an environment where the charset is different from that used to generate the "export -p" output (in practice it is a problem and a source of security vulnerabilities).

And that it would not "restore an exported variable" that was previously unset but exported if the "processing" part sets those variables. Same if "processing" sets the readonly attribute on any of the variables.
Desired ActionChange line 76898 from

   . temp-file

to:

   . ./temp-file

Also, address the other objections in the description if deemed necessary.
Tagstc3-2008

Activities

nick

2019-07-22 15:43

manager   bugnote:0004488

On page 2402 line 76893, change:
    
export PATH=/local/bin:$PATH

to:
    
export PATH="/local/bin:$PATH"


On page 2402 line 76895, change:
   
export −p > temp-file
    unset a lot of variables
    ... processing
    . temp-file

to (note loss of italics on "temp-file"):
    
export −p > temp-file
    unset a lot of variables
    ... processing
    . ./temp-file

Note: If LANG, LC_CTYPE or LC_ALL are left altered or unset in the above example prior to sourcing temp-file, the results may be undefined.

Issue History

Date Modified Username Field Change
2019-06-14 10:56 stephane New Issue
2019-06-14 10:56 stephane Name => Stephane Chazelas
2019-06-14 10:56 stephane Section => export utility
2019-06-14 10:56 stephane Page Number => 2402 (in 2018 edition)
2019-06-14 10:56 stephane Line Number => 76898 (in 2018 edition)
2019-07-22 15:43 nick Note Added: 0004488
2019-07-22 15:44 nick Interp Status => ---
2019-07-22 15:44 nick Status New => Resolved
2019-07-22 15:44 nick Resolution Open => Accepted As Marked
2019-07-22 15:44 nick Final Accepted Text => See 0001258:0004488
2019-07-22 15:44 nick Tag Attached: tc3-2008
2019-11-20 16:01 geoffclare Status Resolved => Applied
2024-06-11 09:08 agadmin Status Applied => Closed