Skip to content

Commit 7e228fd

Browse files
committed
NodeSet CLI: use ''' for separator interpretation
This allows the user to give a litteral new line in -S, so both -S "\n" and -S $'\n' will work Change-Id: If6671ae36936ef5cf224725b0da1a8316f91825e
1 parent 59bd343 commit 7e228fd

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/ClusterShell/CLI/Nodeset.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ def nodeset():
261261
return command_list(options, xset, group_resolver)
262262

263263
# Interprete special characters (may raise SyntaxError)
264-
separator = eval('\'%s\'' % options.separator, {"__builtins__":None}, {})
264+
separator = eval('\'\'\'%s\'\'\'' % options.separator,
265+
{"__builtins__":None}, {})
265266

266267
if options.slice_rangeset:
267268
_xset = class_set()

tests/CLINodesetTest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def test_008_expand_separator(self):
200200
self._nodeset_t(["--expand", "-S", ",", "foo[1-2],bar"], None, b"bar,foo1,foo2\n")
201201
self._nodeset_t(["--expand", "-S", "uuu", "foo[1-2],bar"], None, b"baruuufoo1uuufoo2\n")
202202
self._nodeset_t(["--expand", "-S", "\\n", "foo[1-2]"], None, b"foo1\nfoo2\n")
203+
self._nodeset_t(["--expand", "-S", "\n", "foo[1-2]"], None, b"foo1\nfoo2\n")
203204

204205
def test_009_fold_xor(self):
205206
"""test nodeset --fold --xor"""

0 commit comments

Comments
 (0)