~charles/bem

9fab09102007b42e9b3ab7d69655ce4f6f3e2d09 — Charles Daniels 4 years ago d91e575
handle quoted commands properly
2 files changed, 21 insertions(+), 1 deletions(-)

M README.md
M bem/bem_cli.py
M README.md => README.md +7 -0
@@ 175,3 175,10 @@ be used to create bound volumes. These values do not support indirection (yet).
* `host_path` -- path on the host system
* `container_path` -- path in the container
* `mode` -- `ro` or `rw`

## Known Issues

* Exit codes from processes within the container are not passed back up to the
  caller of BEM.
* Although both stderr and stdout are returned, they are collectively squashed
  into stout.

M bem/bem_cli.py => bem/bem_cli.py +14 -1
@@ 43,6 43,10 @@ def bem_cli():
    parser.add_argument("--noninteractive", "-n", default=None,
            action='store_true', help="Run the command non-interactively")

    parser.add_argument("--nosplit", "-S", default=False, action="store_true",
            help="By default, if the command is of length 1, it is " +
            "automatically run through sh -c. This flag disables this " +
            "behavior.")

    parser.add_argument("command", nargs="+")



@@ 93,7 97,16 @@ def bem_cli():
        logging.error("Configuration error: {}".format(e))
        sys.exit(1)

    bem_engine.execute_command(config, args.command)
    if (len(args.command) == 1) and (not args.nosplit):
        args.command = ["sh", "-c", args.command[0]]

    try:
        bem_engine.execute_command(config, args.command)
    except Exception as e:
        if 'executable file not found in $PATH": unknown' in str(e):
            logging.error("command '{}' not found".format(' '.join(args.command)))
        else:
            logging.error("unhanded exception while executing '{}': {}".format(' '.join(args.command), e))

if __name__ == "__main__":
    bem_cli()