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

How use and operator? #20

Open
MeGaPk opened this issue Sep 13, 2016 · 5 comments
Open

How use and operator? #20

MeGaPk opened this issue Sep 13, 2016 · 5 comments

Comments

@MeGaPk
Copy link

MeGaPk commented Sep 13, 2016

Hello!
I have question.
I have this code:

session := sh.NewSession()
    session.SetTimeout(time.Second * 30)
    session.ShowCMD = true
    session.SetDir(repositoryPath)
    session.Command(
        "rm", "-f", archiveFile, "&&",
        "git", "archive", branchName, "--format", "tar", "--output", archiveFile,
    )

And debug message:
[golang-sh]$ rm -f /tmp/archive.tar && git archive origin/master --format tar --output /tmp/archive.tar
But second command not executed...
If i remove "rm", "-f", archiveFile, "&&",
Its work, but i need this "&&" operator.
What mistake?

@codeskyblue
Copy link
Owner

No. & is not allowed by go-sh

@MeGaPk
Copy link
Author

MeGaPk commented Sep 14, 2016

@codeskyblue Maybe add new command like:
session.And("...") ?
Or write to documentation, that operator && not supported?

@codeskyblue
Copy link
Owner

pr welcome

@mraaroncruz
Copy link

mraaroncruz commented Dec 15, 2017

This is very old, but maybe it will help someone and get this issue closed.

Here's a way to use a &&

./my_script.sh

#!/bin/bash
archive_file=$1
branch=$2
rm -f ${archive_file} && git archive ${branch} --format tar --output ${archive_file}
session := sh.NewSession()
session.SetTimeout(time.Second * 30)
session.ShowCMD = true
session.SetDir(repositoryPath)
session.Command(
    "./my_script.sh", archiveFile, branchName
)

@tgulacsi
Copy link

"rm -f" never returns error...

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

No branches or pull requests

4 participants