File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -166,6 +166,15 @@ jobs:
166166 -Xdemangler=rustfilt \
167167 > lcov.info
168168
169+ - name : --shebang test 1
170+ run : |
171+ echo "#!/usr/bin/env -S pkgx --shebang echo" > ./stub.sh
172+ chmod +x stub.sh
173+ test "$(./stub.sh hi)" = hi
174+
175+ - name : --shebang test 2
176+ run : test $(pkgx -q! echo fail hi) = hi
177+
169178 - uses : coverallsapp/github-action@v2
170179 with :
171180 path-to-lcov : lcov.info
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ regex = "1.11.1"
1414indicatif = " 0.17.9"
1515nix = { version = " 0.29.0" , features = [" process" ] }
1616serde_json = " 1.0.135"
17- libpkgx = { version = " 0.3.2 " , path = " ../lib" }
17+ libpkgx = { version = " 0.4.0 " , path = " ../lib" }
1818console = { version = " 0.15" , default-features = false , features = [
1919 " ansi-parsing" ,
2020] }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ pub struct Flags {
1111 pub silent : bool ,
1212 pub json : bool ,
1313 pub version_n_continue : bool ,
14+ pub shebang : bool ,
1415}
1516
1617pub struct Args {
@@ -31,6 +32,7 @@ pub fn parse() -> Args {
3132 let mut find_program = false ;
3233 let mut collecting_args = false ;
3334 let mut version_n_continue = false ;
35+ let mut shebang = false ;
3436
3537 for arg in std:: env:: args ( ) . skip ( 1 ) {
3638 if collecting_args {
@@ -51,6 +53,7 @@ pub fn parse() -> Args {
5153 }
5254 json = true
5355 }
56+ "--shebang" => shebang = true ,
5457 "--json=v1" => json = true ,
5558 "--silent" => silent = true ,
5659 "--help" => mode = Mode :: Help ,
@@ -92,6 +95,7 @@ pub fn parse() -> Args {
9295 's' => silent = true ,
9396 'j' => json = true ,
9497 'v' => version_n_continue = true ,
98+ '!' => shebang = true ,
9599 _ => panic ! ( "unknown argument: -{}" , c) ,
96100 }
97101 }
@@ -108,6 +112,7 @@ pub fn parse() -> Args {
108112 find_program,
109113 mode,
110114 flags : Flags {
115+ shebang,
111116 silent,
112117 json,
113118 quiet,
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ examples:
1818flags:
1919 -q, --quiet # suppress brief informational messages
2020 -qq, --silent # no chat. no errors. just execute.
21+ -!, --shebang # drops shebang added arg0 for faster pkgx stubs
2122 -v, --version
2223
2324more:
Original file line number Diff line number Diff line change @@ -227,6 +227,11 @@ async fn main() -> Result<(), Box<dyn Error>> {
227227
228228 clear_progress_bar ( ) ;
229229
230+ if flags. shebang {
231+ // removes the filename of the shebang script
232+ args. remove ( 0 ) ;
233+ }
234+
230235 execve ( cmd, args, env)
231236 } else if !plus. is_empty ( ) {
232237 clear_progress_bar ( ) ;
You can’t perform that action at this time.
0 commit comments