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

less than symbol (<) not working correctly for CLI commands #113

Closed
LimeBlast opened this issue Jan 28, 2021 · 3 comments
Closed

less than symbol (<) not working correctly for CLI commands #113

LimeBlast opened this issue Jan 28, 2021 · 3 comments

Comments

@LimeBlast
Copy link

Describe the bug
We're setting up a subcommand which will automatically import a .sql file into mysql running inside a container. This contains the < symbol, as that required to import the dump, but this doesn't seem to work within the dip context.

To Reproduce
Steps to reproduce the behaviour:

# dip.yml
  mysql:
    description: Run mysql console
    service: mysql
    command: mysql -h mysql_no -u root -d app_development
    subcommands:
      import:
        description: import the specified file into the development database
        service: mysql
        command: mysql -h mysql -u root -proot app_development < MySQL.sql
# command run
$ dip mysql import
# Output
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql  Ver 14.14 Distrib 5.7.33, for Linux (x86_64) using  EditLine wrapper
Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Usage: mysql [OPTIONS] [database]
  -?, --help          Display this help and exit.
  -I, --help          Synonym for -?
snip...

We've been able to bypass this by removing the < MySQL.sql portion of the command, and instead passing that in via the CLI when we run the command, i.e. dip mysql import < MySQL.sql - but would prefer for it to be all inclusive within the dip.yml file.

Expected behavior
It should import the database

Context (please complete the following information):

  • OS: MacOS 11.1
  • Version 6.1.0
@bibendi
Copy link
Owner

bibendi commented Jan 28, 2021

Yep, this is expected behavior.
We run a command through Process.exec

::Process.exec(env, cmd, *argv, options)

where arguments are passed as Array. And that's why we cannot use special symbols.
https://www.rubydoc.info/stdlib/core/Process.exec
Ruby invokes the command directly without the shell.
I'm trying to remember the reason why I choose that, but I can't :)
So, I need time to investigate it again, but I don't promise you that it will be fast because I little bit swamped on the current project.

@LimeBlast
Copy link
Author

Does this mean we can define < symbols in the commands now?

@bibendi
Copy link
Owner

bibendi commented Mar 31, 2021

Yeap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants