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

Unix combine commands with && does not work #79

Closed
Kasheftin opened this issue Apr 20, 2017 · 4 comments
Closed

Unix combine commands with && does not work #79

Kasheftin opened this issue Apr 20, 2017 · 4 comments
Assignees
Labels

Comments

@Kasheftin
Copy link

That's my typical config I use for years:

config.exec: {
  sources: {
    cmd: 
      "mkdir build/fonts/bootstrap"+
      " && "
      "cp -r vendor/bootstrap-sass/assets/fonts/bootstrap/* build/fonts/bootstrap"+
      " && "
      ...
   }
}

It works fine with 1.0.1. It does not work with 2.0.0.

@gwicksted
Copy link
Collaborator

I'll fire up a Linux VM and test. Can you send me the error message? The following is working for me in Windows:

test_multiple_commands: {
      cmd: 
        process.platform === "win32" ? 
              "(rmdir /s /q build || echo 'no build dir')" +
              " && " +
              "mkdir build" +
              " && " +
              "copy * build" +
              " && " +
              "echo done"
            : "rm -rf build" +
              " && " +
              "cp * build" +
              " && " +
              "echo done"
    }

@gwicksted gwicksted self-assigned this Apr 20, 2017
@gwicksted gwicksted added the bug label Apr 20, 2017
@Kasheftin
Copy link
Author

Anything with && works incorrect (and with ; as well). For example, echo 1 && echo 2 should output 1 and 2.
That's the exact code:

module.exports = function(grunt) {
  config.exec = {
    test: {
      cmd: "echo 1 && echo 2"
    }
  }
  grunt.initConfig(config);
  grunt.loadNpmTasks("grunt-exec");
  grunt.registerTask("test",["exec:test"]);
}

There's splitArgs function, it count everything after the first space as command argument. That's the grunt test --verbose result:

Running "exec:test" (exec) task
Verifying property exec.test exists in config...OK
File: [no files]    

echo 1 && echo 2
buffer   : disabled
timeout  : infinite
killSig  : SIGTERM
shell    : true
command  : echo
args     : [1,&&,echo,2]
stdio    : [ignore,pipe,pipe]
cwd      : /home/www/obzor/html/tools
exitcodes: 0
pid     : 23072
>> Exited with code: 0.
1 && echo 2

So the result is 1 && echo 2 - everything after the first space counts as the first echo's command argument.

@kiyanwang
Copy link

having the same problem as @Kasheftin any thoughts on how to resolve this?

@gwicksted
Copy link
Collaborator

Fixed. Please retry with grunt-exec 3.0.0 (bumped major due to possibly breaking changes relying on incorrect quote/space handling of v2 on non-win32).

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

No branches or pull requests

3 participants