From 6cd79838c668abc3c70b2fd5f7c1a7aa2636c1b9 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 8 Oct 2023 16:43:39 +0200 Subject: [PATCH] output to stderr, check if directory exists --- .config/fish/functions/makeaway.fish | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.config/fish/functions/makeaway.fish b/.config/fish/functions/makeaway.fish index c103f86..059322c 100644 --- a/.config/fish/functions/makeaway.fish +++ b/.config/fish/functions/makeaway.fish @@ -8,6 +8,13 @@ function makeaway return 0 end + # Check if directory exists + set directory $argv[1] + if not test -d $directory + echo "Directory doesn't exists." 1>&2 + return 1 + end + # Find the target set target "" if test (count $argv) -ge 3 && test "$argv[2]" = -- @@ -15,12 +22,12 @@ function makeaway set target $argv[3] else if test (count $argv) -ge 2 && test "$argv[2]" = -- # User used "--" without target - echo "No target found." + echo "No target found." 1>&2 return 1 end # Make - cd $argv[1] + cd $directory make $target cd - end