debian: stx: shell: support multi-line commands

The "stx shell" command fails if the command being executed ends with a
newline. Root cause: we always wrap user command in
"{ $USER_COMMAND ; }", but in shell a line can't start with a ";".

Solution: strip the command before evaluating.

TESTS
===================================
Test "stx shell" with the following commands
- empty command
- multiple commands one one line
- multiple commands on a multiple lines

Story: 2010055
Task: 45486

Signed-off-by: Davlet Panech <davlet.panech@windriver.com>
Change-Id: Ib55a07129d68402193869ca94196d94d540ec841
This commit is contained in:
Davlet Panech 2022-06-09 21:55:56 -04:00
parent 22e65468cf
commit a8342414c3
1 changed files with 1 additions and 1 deletions

View File

@ -84,7 +84,7 @@ class HandleShellTask:
else:
user_cmd += 'bash --norc -c '
user_cmd += quote('source %s && { %s ; }' %
(req_env_file, command))
(req_env_file, command.strip() or ':'))
kubectl_args += ['--', 'bash', '-l', '-c', user_cmd]