Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove trailing semicolons from output #101

Merged
merged 2 commits into from Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/config_file.md
Expand Up @@ -18,11 +18,11 @@ This will then be converted into the correct format for whatever shell is being
For example, in **bash**, this line becomes:

```bash
export CARGO_HOME=${XDG_DATA_HOME}'/cargo';
export CARGO_HOME=${XDG_DATA_HOME}'/cargo'
```
While in **fish**, this line is:
```fish
set -gx CARGO_HOME {$XDG_DATA_HOME}'/cargo';
set -gx CARGO_HOME {$XDG_DATA_HOME}'/cargo'
```

#### Special value expansions
Expand Down
118 changes: 59 additions & 59 deletions src/convert/mod.rs
Expand Up @@ -106,7 +106,7 @@ mod add_script_line {
};

*output += value;
*output += ";\n";
*output += "\n";
}

pub fn unset_variable(output: &mut String, shell: &Shell, name: &str) {
Expand All @@ -123,7 +123,7 @@ mod add_script_line {
}
};

*output += ";\n";
*output += "\n";
}
}

Expand Down Expand Up @@ -252,9 +252,9 @@ mod test_conversion {
},
// language=sh
hashmap! {
Shell::Bash => r#"export FOO='Bar';"#,
Shell::Zsh => r#"export FOO='Bar';"#,
Shell::Fish => r#"set -gx FOO 'Bar';"#,
Shell::Bash => r#"export FOO='Bar'"#,
Shell::Zsh => r#"export FOO='Bar'"#,
Shell::Fish => r#"set -gx FOO 'Bar'"#,
},
)
}
Expand All @@ -275,9 +275,9 @@ mod test_conversion {
},
// language=sh
hashmap! {
Shell::Bash => r#"export PATH='/usr/local/bin':'/usr/bin':'/bin':'/usr/sbin':'/sbin';"#,
Shell::Zsh => r#"export PATH='/usr/local/bin':'/usr/bin':'/bin':'/usr/sbin':'/sbin';"#,
Shell::Fish => r#"set -gx --path PATH '/usr/local/bin':'/usr/bin':'/bin':'/usr/sbin':'/sbin';"#,
Shell::Bash => r#"export PATH='/usr/local/bin':'/usr/bin':'/bin':'/usr/sbin':'/sbin'"#,
Shell::Zsh => r#"export PATH='/usr/local/bin':'/usr/bin':'/bin':'/usr/sbin':'/sbin'"#,
Shell::Fish => r#"set -gx --path PATH '/usr/local/bin':'/usr/bin':'/bin':'/usr/sbin':'/sbin'"#,
},
)
}
Expand All @@ -292,9 +292,9 @@ mod test_conversion {
},
// language=sh
hashmap! {
Shell::Bash => r#"export HOMEBREW_NO_ANALYTICS=1;"#,
Shell::Zsh => r#"export HOMEBREW_NO_ANALYTICS=1;"#,
Shell::Fish => r#"set -gx HOMEBREW_NO_ANALYTICS 1;"#,
Shell::Bash => r#"export HOMEBREW_NO_ANALYTICS=1"#,
Shell::Zsh => r#"export HOMEBREW_NO_ANALYTICS=1"#,
Shell::Fish => r#"set -gx HOMEBREW_NO_ANALYTICS 1"#,
},
)
}
Expand All @@ -309,9 +309,9 @@ mod test_conversion {
},
// language=sh
hashmap! {
Shell::Bash => r#"unset HOMEBREW_NO_ANALYTICS;"#,
Shell::Zsh => r#"unset HOMEBREW_NO_ANALYTICS;"#,
Shell::Fish => r#"set -ge HOMEBREW_NO_ANALYTICS;"#,
Shell::Bash => r#"unset HOMEBREW_NO_ANALYTICS"#,
Shell::Zsh => r#"unset HOMEBREW_NO_ANALYTICS"#,
Shell::Fish => r#"set -ge HOMEBREW_NO_ANALYTICS"#,
},
)
}
Expand All @@ -328,7 +328,7 @@ mod test_conversion {
},
// language=sh
hashmap! {
Shell::Bash => r#"export ONLY_FOR_BASH='Do people read test cases?';"#,
Shell::Bash => r#"export ONLY_FOR_BASH='Do people read test cases?'"#,
Shell::Zsh => "",
Shell::Fish => "",
},
Expand All @@ -351,9 +351,9 @@ mod test_conversion {
},
// language=sh
hashmap! {
Shell::Bash => r#"export SOME_VARIABLE='[ACCESS DENIED]';"#,
Shell::Zsh => r#"export SOME_VARIABLE='[ACCESS DENIED]';"#,
Shell::Fish => r#"set -gx SOME_VARIABLE 'you\'re pretty';"#,
Shell::Bash => r#"export SOME_VARIABLE='[ACCESS DENIED]'"#,
Shell::Zsh => r#"export SOME_VARIABLE='[ACCESS DENIED]'"#,
Shell::Fish => r#"set -gx SOME_VARIABLE 'you\'re pretty'"#,
},
)
}
Expand Down Expand Up @@ -381,12 +381,12 @@ mod test_conversion {
},
// language=sh
hashmap! {
Shell::Bash => r#"export SOME_VARIABLE='[ACCESS DENIED]';"#,
Shell::Bash => r#"export SOME_VARIABLE='[ACCESS DENIED]'"#,
Shell::Zsh => indoc! (r#"
export SOME_VARIABLE='[ACCESS DENIED]';
export ANOTHER_VARIABLE='Zzz';
export SOME_VARIABLE='[ACCESS DENIED]'
export ANOTHER_VARIABLE='Zzz'
"#),
Shell::Fish => r#"set -gx SOME_VARIABLE 'you\'re pretty';"#,
Shell::Fish => r#"set -gx SOME_VARIABLE 'you\'re pretty'"#,
},
)
}
Expand All @@ -401,9 +401,9 @@ mod test_conversion {
},
// language=sh
hashmap! {
Shell::Bash => r#"export WHERE_THE_HEART_IS=${HOME};"#,
Shell::Zsh => r#"export WHERE_THE_HEART_IS=${HOME};"#,
Shell::Fish => r#"set -gx WHERE_THE_HEART_IS {$HOME};"#,
Shell::Bash => r#"export WHERE_THE_HEART_IS=${HOME}"#,
Shell::Zsh => r#"export WHERE_THE_HEART_IS=${HOME}"#,
Shell::Fish => r#"set -gx WHERE_THE_HEART_IS {$HOME}"#,
},
)
}
Expand All @@ -418,9 +418,9 @@ mod test_conversion {
},
// language=sh
hashmap! {
Shell::Bash => r#"export AN_EXAMPLE=${HOME}'less';"#,
Shell::Zsh => r#"export AN_EXAMPLE=${HOME}'less';"#,
Shell::Fish => r#"set -gx AN_EXAMPLE {$HOME}'less';"#,
Shell::Bash => r#"export AN_EXAMPLE=${HOME}'less'"#,
Shell::Zsh => r#"export AN_EXAMPLE=${HOME}'less'"#,
Shell::Fish => r#"set -gx AN_EXAMPLE {$HOME}'less'"#,
},
)
}
Expand All @@ -435,9 +435,9 @@ mod test_conversion {
},
// language=sh
hashmap! {
Shell::Bash => r#"export EDITOR=$(eval 'which micro');"#,
Shell::Zsh => r#"export EDITOR=$(eval 'which micro');"#,
Shell::Fish => r#"set -gx EDITOR (eval 'which micro');"#,
Shell::Bash => r#"export EDITOR=$(eval 'which micro')"#,
Shell::Zsh => r#"export EDITOR=$(eval 'which micro')"#,
Shell::Fish => r#"set -gx EDITOR (eval 'which micro')"#,
},
)
}
Expand All @@ -452,9 +452,9 @@ mod test_conversion {
},
// language=sh
hashmap! {
Shell::Bash => r#"export HOME=$(eval echo "~superatomic");"#,
Shell::Zsh => r#"export HOME=$(eval echo "~superatomic");"#,
Shell::Fish => r#"set -gx HOME (eval echo "~superatomic");"#,
Shell::Bash => r#"export HOME=$(eval echo "~superatomic")"#,
Shell::Zsh => r#"export HOME=$(eval echo "~superatomic")"#,
Shell::Fish => r#"set -gx HOME (eval echo "~superatomic")"#,
},
)
}
Expand All @@ -476,16 +476,16 @@ mod test_conversion {
// language=sh
hashmap! {
Shell::Bash => indoc!(r#"
export MESSAGE='$() is literal, and '$(eval 'echo '"'"')'"'")' is escaped.';
export FAVORITE_CHARACTER='\';
export MESSAGE='$() is literal, and '$(eval 'echo '"'"')'"'")' is escaped.'
export FAVORITE_CHARACTER='\'
"#),
Shell::Zsh => indoc!(r#"
export MESSAGE='$() is literal, and '$(eval 'echo '"'"')'"'")' is escaped.';
export FAVORITE_CHARACTER='\';
export MESSAGE='$() is literal, and '$(eval 'echo '"'"')'"'")' is escaped.'
export FAVORITE_CHARACTER='\'
"#),
Shell::Fish => indoc!(r#"
set -gx MESSAGE '$() is literal, and '(eval 'echo \')\'')' is escaped.';
set -gx FAVORITE_CHARACTER '\\';
set -gx MESSAGE '$() is literal, and '(eval 'echo \')\'')' is escaped.'
set -gx FAVORITE_CHARACTER '\\'
"#),
},
)
Expand All @@ -501,9 +501,9 @@ mod test_conversion {
},
// language=sh
hashmap! {
Shell::Bash => r#"export MESSAGE='I '"'"'love'"'"' books';"#,
Shell::Zsh => r#"export MESSAGE='I '"'"'love'"'"' books';"#,
Shell::Fish => r#"set -gx MESSAGE 'I \'love\' books';"#,
Shell::Bash => r#"export MESSAGE='I '"'"'love'"'"' books'"#,
Shell::Zsh => r#"export MESSAGE='I '"'"'love'"'"' books'"#,
Shell::Fish => r#"set -gx MESSAGE 'I \'love\' books'"#,
},
)
}
Expand Down Expand Up @@ -541,26 +541,26 @@ mod test_conversion {
// language=sh
hashmap! {
Shell::Bash => indoc! (r#"
export FOO='bar';
export BAZ=$(eval echo "~other");
export TTY=$(eval 'tty');
export THE_ECHO=$(eval 'echo ")"');
export XSHE_IS_THE_BEST=1;
unset XDG_CONFIG_HOME;
export FOO='bar'
export BAZ=$(eval echo "~other")
export TTY=$(eval 'tty')
export THE_ECHO=$(eval 'echo ")"')
export XSHE_IS_THE_BEST=1
unset XDG_CONFIG_HOME
"#),
Shell::Zsh => indoc! (r#"
export FOO='bar';
export BAZ='zž';
export TTY=$(eval 'tty');
export THE_ECHO=$(eval 'echo ")"');
export XSHE_IS_THE_BEST=1;
export FOO='bar'
export BAZ='zž'
export TTY=$(eval 'tty')
export THE_ECHO=$(eval 'echo ")"')
export XSHE_IS_THE_BEST=1
"#),
Shell::Fish => indoc! (r#"
set -gx FOO 'bar';
set -gx --path BAZ 'gone':{$fishing};
set -gx TTY (eval 'tty');
set -gx THE_ECHO (eval 'echo ")"');
set -gx XSHE_IS_THE_BEST 1;
set -gx FOO 'bar'
set -gx --path BAZ 'gone':{$fishing}
set -gx TTY (eval 'tty')
set -gx THE_ECHO (eval 'echo ")"')
set -gx XSHE_IS_THE_BEST 1
"#),
},
)
Expand Down