Skip to content

Commit

Permalink
Add a test for arg0 setting
Browse files Browse the repository at this point in the history
  • Loading branch information
fornwall committed Sep 26, 2023
1 parent 19d9cb7 commit 2b8ca0c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/scripts/arg0.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["./subdir/myscript.rs"]
19 changes: 19 additions & 0 deletions tests/scripts/arg0.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
set -e -u

# See https://github.com/fornwall/rust-script/issues/113

mytmpdir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
mkdir $mytmpdir/subdir
cd "$mytmpdir"

cat > subdir/myscript.rs << EOF
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
println!("{:?}", args);
}
EOF

rust-script ./subdir/myscript.rs

0 comments on commit 2b8ca0c

Please sign in to comment.