Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 84967 - runscript breaks when changing IFS (Internal Field Seperator)
Summary: runscript breaks when changing IFS (Internal Field Seperator)
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-12 05:49 UTC by omri
Modified: 2005-03-12 08:46 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description omri 2005-03-12 05:49:26 UTC
Some operations (such as restarting a service) break when changing the IFS variable in the script.

Reproducible: Always
Steps to Reproduce:
1. Create the following init script:
#!/sbin/runscript
start() {
        ebegin "start"
        IFS=""
        eend 0
}
stop() {
        ebegin "stop"
        IFS=""
        eend 0
}
2. Start the service
3. Restart the service

Actual Results:  
Syntax errors

Expected Results:  
Whenever a script (or a function, such as stop or start) finishes, runscript
should restore the variables, IFS among them.


This specific script can be repaird as follows:
#!/sbin/runscript

start() {
        ebegin "start"
        IFS=""
        IFS=$' \t\n'
        eend 0
}
stop() {
        ebegin "stop"
        IFS=""
        IFS=$' \t\n'
        eend 0
}

#eof

At the moment, I advice all programmers to store a backup of the important
variables and restore them at the end of the script.
In this workaround I've restored the default bash value for IFS, which runscript
expects.
Comment 1 Martin Schlemmer (RETIRED) gentoo-dev 2005-03-12 08:46:15 UTC
Rather make all variable you change local, which should be the good bash practice:

-----
 $  (foo(){ local IFS="|"; echo "$*"; }; foo bar boo ban)
bar|boo|ban
-----