Commit 935811ea authored by Luke Clifton's avatar Luke Clifton

Fix set and status argument handling

parent 4fe023a7
......@@ -38,6 +38,7 @@ BASH EQUIVALENTS
pub fn set(args: &[types::Str], shell: &mut Shell<'_>) -> Status {
let mut args_iter = args.iter();
let mut positionals = None;
args_iter.next();
while let Some(arg) = args_iter.next() {
match arg.as_str() {
......
......@@ -30,7 +30,15 @@ pub fn status(args: &[types::Str], shell: &mut Shell<'_>) -> Status {
let is_login = env::args().nth(0).unwrap().chars().nth(0).unwrap() == '-';
match args.len() {
0 => {
1 => {
if is_login {
println!("This is a login shell");
} else {
println!("This is not a login shell");
}
Status::SUCCESS
}
_ => {
for arg in args {
match &**arg {
"--is-login" => login_shell = true,
......@@ -70,14 +78,5 @@ pub fn status(args: &[types::Str], shell: &mut Shell<'_>) -> Status {
Status::TRUE
}
1 => {
if is_login {
println!("This is a login shell");
} else {
println!("This is not a login shell");
}
Status::SUCCESS
}
_ => Status::error("status takes one argument"),
}
}
set -e
false
echo unreachable
ion: pipeline execution error: early exit: pipeline failed
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment