mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-26 03:19:48 +00:00
Rework check_globbing to reduce false positives
First, globbing can only be the cause of a mess up if the given noderange is a file that matches. With this we still have: for node in $(nodelist compute); do nodepower $node; done As a potential false positive if any node is a range. For this, offer suggestion of changing directories. Also, if it had been: for NODE in $(nodelist compute); do export NODE; nodepower $NODE; done Another clause can detect that, which has been added.
This commit is contained in:
parent
4bef5f7917
commit
d69cca46d0
@ -469,15 +469,24 @@ def updateattrib(session, updateargs, nodetype, noderange, options):
|
||||
# if we glob to something, then bash will change noderange and this should
|
||||
# detect it and save the user from tragedy
|
||||
def check_globbing(noderange):
|
||||
if not os.path.exists(noderange):
|
||||
return True
|
||||
rawargs = os.environ.get('CURRENT_CMDLINE', None)
|
||||
if rawargs:
|
||||
rawargs = shlex.split(rawargs)
|
||||
for arg in rawargs:
|
||||
if arg.startswith('$'):
|
||||
arg = arg[1:]
|
||||
if arg.endswith(';'):
|
||||
arg = arg[:-1]
|
||||
arg = os.environ.get(arg, '$' + arg)
|
||||
if arg.startswith(noderange):
|
||||
break
|
||||
else:
|
||||
sys.stderr.write(
|
||||
'Shell glob conflict detected, specified target {0} '
|
||||
'not in command line (if bash, try set -f)'
|
||||
'Shell glob conflict detected, specified target "{0}" '
|
||||
'not in command line, but is a file. You can use "set -f" in '
|
||||
'bash or change directories such that there is no filename '
|
||||
'that would conflict.'
|
||||
'\n'.format(noderange))
|
||||
sys.exit(1)
|
Loading…
Reference in New Issue
Block a user