rc.subr: disabling globbing while processing devfs rules

The rules themselves typically have shell-like patterns and it is
incorrect when they get replaced with matching filesystem entries.

Shell magic by:	jilles
MFC after:	2 weeks
This commit is contained in:
Andriy Gapon 2013-03-28 08:13:52 +00:00
parent bafa6cfc93
commit 3ee030e1e9

View File

@ -1285,7 +1285,7 @@ make_symlink()
# #
devfs_rulesets_from_file() devfs_rulesets_from_file()
{ {
local file _err _me local file _err _me _opts
file="$1" file="$1"
_me="devfs_rulesets_from_file" _me="devfs_rulesets_from_file"
_err=0 _err=0
@ -1298,6 +1298,11 @@ devfs_rulesets_from_file()
debug "$_me: no such file ($file)" debug "$_me: no such file ($file)"
return 0 return 0
fi fi
# Disable globbing so that the rule patterns are not expanded
# by accident with matching filesystem entries.
_opts=$-; set -f
debug "reading rulesets from file ($file)" debug "reading rulesets from file ($file)"
{ while read line { while read line
do do
@ -1344,6 +1349,7 @@ devfs_rulesets_from_file()
break break
fi fi
done } < $file done } < $file
case $_opts in *f*) ;; *) set +f ;; esac
return $_err return $_err
} }