How to do whilespace-insensitive string compare in fish: Difference between revisions

From razwiki
Jump to navigation Jump to search
(Created page with "The problem: test "a b " = "a b" exits with 1; this comes up with `fish_postexec`: if test "$argv" = "$EDITOR ~/.profile" -> test vim ~/.profile = vim ~/.profile whic...")
 
 
Line 17: Line 17:
== See also ==
== See also ==


How to automatically source ~/.profile after editing it in fish shell
[[How to automatically source ~/.profile after editing it in fish shell]]

Latest revision as of 12:20, 6 December 2021

The problem:

test "a b " = "a b"

exits with 1; this comes up with `fish_postexec`:

if test "$argv" = "$EDITOR ~/.profile"
->
test vim ~/.profile  = vim ~/.profile

which itself happens because tab completion adds a space at the end.

Solution:

test (echo "$argv" | string trim) = "$EDITOR ~/.profile"

See also

How to automatically source ~/.profile after editing it in fish shell