Skip to content

Commit

Permalink
bugfix: args now passed to non-source scripts
Browse files Browse the repository at this point in the history
Fixes #16. Previously arguments were not passed into non-source
scripts, which made common use cases of parameterized scripts
impossible.
  • Loading branch information
toumorokoshi committed Nov 16, 2021
1 parent 34dd5b7 commit 356710f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/commands/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl Script {
}
}

// return the appropriate string that should be exeucted within the
// return the appropriate string that should be executed within the
// function.
pub fn get_execution_body(
&self,
Expand Down Expand Up @@ -125,7 +125,11 @@ impl Script {
}
command
} else {
vec![self.path.clone()]
let mut command = vec![self.path.clone()];
for arg in args.iter() {
command.push((**arg).clone());
}
command
};
// after figuring out the command, all resolved values
// should be quoted, to ensure that the shell does not
Expand Down
9 changes: 9 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ fn test_simple_script() {
);
}

/// the output should be the path to the script itself, with the passed arguments
#[test]
fn test_simple_script_with_args() {
assert_eq!(
execute(_vec_str(vec!["tome", EXAMPLE_DIR, "file_example", "x"])),
Ok(format!("'{}/file_example' 'x'", EXAMPLE_DIR))
);
}

#[test]
fn test_simple_script_completion() {
assert_eq!(
Expand Down

0 comments on commit 356710f

Please sign in to comment.