---
feature_story: FS_92_75_93_01
feature_title: clean command line
feature_status: TODO
---

# Problem statement

If `ARGRELAY_DEBUG` is defined, it is possible to observe what command line argrelay client receives:

```sh
export ARGRELAY_DEBUG=""
```

Consider few cases:

1.  Command line with comment:

    ```sh
    relay_demo some_arg # comment
    ```

2.  Command line with piped command:

    ```sh
    relay_demo some_arg | cat
    ```

3.  Command line with sub-shell:

    ```sh
    echo $( relay_demo some_arg )
    ```

There is a difference how clean command line of unrelated chars is (depending on the action):

*   `ServerAction.DescribeLineArgs`

    This action has the dirtiest command line (Bash simply sends entire command line string):

    1.
    ```
    "relay_demo some_arg # comment" cursor_cpos: 19 comp_type: 94
    ```

    2.
    ```
    "relay_demo some_arg | cat" cursor_cpos: 19 comp_type: 94
    ```

    3.
    ```
    "echo $( relay_demo some_arg )" cursor_cpos: 27 comp_type: 94
    ```

*   `ServerAction.ProposeArgValues`

    This action is relatively safe from mis-interpretation, however, comments (after `#`) may still affect the results.

    1.
    ```
    "relay_demo some_arg # comment" cursor_cpos: 19 comp_type: 33
    ```

    2.
    ```
    "relay_demo some_arg " cursor_cpos: 19 comp_type: 33
    ```

    3.  Bash does not invoke completion for command in sub-shell expression.


*   `ServerAction.RelayLineArgs`

    This is the cleanest action.<br/>
    This is largely because the line is actually parsed by Bash first.<br/>
    Then, all args (passed by Bash) related to the command in question are simply concatenated on the client side.

    1.
    ```
    "relay_demo some_arg" cursor_cpos: 19 comp_type: 42
    ```

    2.
    ```
    "relay_demo some_arg" cursor_cpos: 19 comp_type: 42
    ```

    3.
    ```
    "relay_demo some_arg" cursor_cpos: 19 comp_type: 42
    ```

The problem is that, depending on the extra chars, the interpretation outcome is different.

# Bash version

The Bash version test results were obtained for:

```
bash --version
GNU bash, version 5.2.15(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
```
