Fix an issue with test -n
- ID
92ec5d4- date
2024-01-22 10:22:54+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
1a0bbe6- message
Fix an issue with `test -n` See https://github.com/alexwlchan/til/blob/main/fish/Beware%20of%20using%20%60test%20-n%60%20with%20command%20expansion.md- changed files
1 file, 4 additions, 1 deletion
Changed files
config.fish (6668) → config.fish (6739)
diff --git a/config.fish b/config.fish
index e4f624e..a3c0b80 100644
--- a/config.fish
+++ b/config.fish
@@ -161,7 +161,10 @@ function __create_python_module_alias
# If we're in a virtualenv where this module is installed, we
# should prefer the virtualenv version over the version in scripts.
function $module_name --inherit-variable module_name
- if test -n (which $module_name)
+ which $module_name >/dev/null 2>&1
+
+ if test $status -eq 0
+ echo "it's in the venv!"
set executable (which $module_name)
$executable $argv
else