skywind3000 / atom-shell-commands

Execute user defined shell commands (looking for new maintainers)
MIT License
36 stars 12 forks source link

How can I put an argument in quotation marks #22

Open Plusle opened 7 years ago

Plusle commented 7 years ago

For my linux, I wanna run my program in a new terminal. I try to add a command like this:

gnome-terminal -x bash -c "./filename;exec bash;"

but this plugin may not support escape character, so I can't add it correctly. what else method can I try?

my config:

      {
        name: "run-it"
        command: "gnome-terminal"
        arguments: [
          "-x"
          "bash"
          "-c"
          "./{FileNameNoExt};exec bash;"
        ]
        options:
          cwd: "{FileDir}"
          keymap: "f6"
      }
dqsully commented 7 years ago

How about this:

      {
        name: "run-it"
        command: "gnome-terminal"
        arguments: [
          "-x"
          "bash"
          "-c"
          "\"./{FileNameNoExt};exec bash;\""
        ]
        options:
          cwd: "{FileDir}"
          keymap: "f6"
      }

Because the Atom configuration file is written in CSON, you can use escape characters in the strings, including escaping the double quote ("), or you could write your string in single quotes and skip having to escape the double quotes, like this: '"./{FileNameNoExt};exec bash;"'

Plusle commented 7 years ago

@dqsully thx for your replying This morning I remember the feature about " and ',sorry for my poor js knowlegde. But I have tried coffeescript "\"./{FileNameNoExt};exec bash;\"", it didn't run correctly. Now I'm using win, so I can't take a screenshot. I will verify the escape characters one one more time, if there is still a error, I will take a screenshot here.

dqsully commented 7 years ago

There may be a quirk with Node about the quotation marks inside the argument. I remember something about this when developing my fork of this package. I'm away right now so I can't help you yet, but you may try my fork dqs-shell-commands. However I have no idea about Linux compatibility as the moment. I am actually in the process of overhauling my package right now so I will try to fix this issue if we don't find another solution.