简体   繁体   中英

How to handle commands containing “-” in python sh module?

I need to git-archive using Python sh module . The command is:

git archive --format tar HEAD

but it seems it's complicated to handle commands containing arguments or - . For example git ls-files I can't do git.sh.ls-files

The foo.bar.baz syntax is intended as a special-case convenience feature; it's not by any means obligatory. If you can't use it, don't. Thus:

sh.git('ls-files')

This follows for more complex commands as well:

sh.git('archive', '--format', 'tar')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM