Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal to add quoted parameters for command line arguments #46

Open
pawelkax opened this issue Sep 26, 2018 · 0 comments
Open

Proposal to add quoted parameters for command line arguments #46

pawelkax opened this issue Sep 26, 2018 · 0 comments

Comments

@pawelkax
Copy link

pawelkax commented Sep 26, 2018

Hi,
Could we have opportunity in configshell-fb to pass quoted strings as arguments?
It would be nice to have it. In our software we use whitespace separated arguments
and we also create similar program to targetcli based on configshell. We would like to have compatibility in our code.
Passing such string should work: sample_arg="test test1"

The proposed code would look like this (it is taken from Datera/configshell#2):

diff --git a/configshell/shell.py b/configshell/shell.py
index bb4dd32..f4caa94 100644
--- a/configshell/shell.py
+++ b/configshell/shell.py
@@ -19,7 +19,8 @@ import os
 import six
 import sys
 from pyparsing import (alphanums, Empty, Group, OneOrMore, Optional,
-                       ParseResults, Regex, Suppress, Word)
+                       ParseResults, Regex, Suppress, Word,
+                       QuotedString, Or)

 from . import console
 from . import log
@@ -119,7 +120,8 @@ class ConfigShell(object):
         # Grammar of the command line
         command = locatedExpr(Word(alphanums + '_'))('command')
         var = Word(alphanums + ';,=_\+/.<>()~@:-%[]')
-        value = var
+        qvar = QuotedString('"', unquoteResults=True)
+        value = Or([qvar, var])
         keyword = Word(alphanums + '_\-')
         kparam = locatedExpr(keyword + Suppress('=') + Optional(value, default=''))('kparams*')
         pparam = locatedExpr(var)('pparams*')

Thanks,
Pawel

jimharris pushed a commit to spdk/spdk that referenced this issue Oct 1, 2018
Override configshell constructor to allow command paramaters to use
whitespaces and quotes.

"This patch will be obsolete once
open-iscsi/configshell-fb#46 is fixed."

Change-Id: Ia5f883991b031901be7dadf61cbe7ebdcf5a9cb7
Signed-off-by: Karol Latecki <[email protected]>
Signed-off-by: Pawel Kaminski <[email protected]>
Reviewed-on: https://review.gerrithub.io/426037
Tested-by: SPDK CI Jenkins <[email protected]>
Reviewed-by: Jim Harris <[email protected]>
Reviewed-by: Shuhei Matsumoto <[email protected]>
Chandler-Test-Pool: SPDK Automated Test System <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant