GitHub user YoungForest opened a pull request:

    https://github.com/apache/incubator-hawq/pull/1333

    HAWQ-1582. hawq ssh cmd bug when pipe in cmd

    # Bug description
    [HAWQ-1582](https://issues.apache.org/jira/browse/HAWQ-1582)
    
    # Bug reason
    
https://github.com/apache/incubator-hawq/blob/037be68ffacdac09dbecef22951ffa97bd9acb4a/tools/bin/hawq#L94
    Joining all arguments with space raises this bug when there is space in a 
argument. For example, argument`'ls -1 | wc -l'` becomes several arguments 
`'ls', '-1', '|', 'wc', '-l'`, which are feed into `subprocess.Popen`
    
https://github.com/apache/incubator-hawq/blob/037be68ffacdac09dbecef22951ffa97bd9acb4a/tools/bin/hawq#L41
    For example, when executing `hawk ssh -h localhost -e 'ls -1 | wc -l'`, the 
`gpssh -h localhost -e ls -1 | wc -l` is feed into `subprocess.Popen` as cmd, 
while cmd is expected to be `gpssh -h localhost -e 'ls -1 | wc -l'`.
    
    # How I fix it
    
[commit](https://github.com/YoungForest/incubator-hawq/commit/9ce5be82dcab0c53ab848178e1b4d8ec99a91a2e)
    Not just join arguments with space simply, while keep its integrity when 
the argument has space in it.
    
    Fix result:
    ``` bash
    hawq ssh -h sdw2 -h localhost -e 'ls -1 | wc -l'
    ``` 
    gets expected result.
    
    ``` bash
    hawq ssh -h sdw2 -h localhost -e 'kill -9 \$(pgrep lava)'
    ```
    gets expected result too after adding escape before `$`.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/YoungForest/incubator-hawq HAWQ-1582

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-hawq/pull/1333.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1333
    
----
commit 9ce5be82dcab0c53ab848178e1b4d8ec99a91a2e
Author: YoungForest <yangsen758@...>
Date:   2018-01-24T02:46:18Z

    HAWQ-1582. hawq ssh cmd bug when pipe in cmd

----


---

Reply via email to