From 725febb669aae1840d98815cfaf1a39af2009036 Mon Sep 17 00:00:00 2001 From: David Adam Date: Thu, 14 Sep 2017 12:30:04 +0800 Subject: [PATCH] Revert "convert `popd` and `pushd` to use `argparse`" This reverts commit 05aae4764b90aab9fec813485a6fa6a2d142825c. Closes #4398. --- share/functions/popd.fish | 14 +++++++------- share/functions/pushd.fish | 19 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/share/functions/popd.fish b/share/functions/popd.fish index ec40b5317..69eda0862 100644 --- a/share/functions/popd.fish +++ b/share/functions/popd.fish @@ -1,11 +1,11 @@ -function popd --description "Pop directory from the stack and cd to it" - set -l options 'h/help' - argparse -n popd --max-args=0 $options -- $argv - or return - if set -q _flag_help - __fish_print_help popd - return 0 +function popd --description "Pop directory from the stack and cd to it" + if count $argv >/dev/null + switch $argv[1] + case -h --h --he --hel --help + __fish_print_help popd + return 0 + end end if set -q dirstack[1] diff --git a/share/functions/pushd.fish b/share/functions/pushd.fish index 52af5c466..47c16db22 100644 --- a/share/functions/pushd.fish +++ b/share/functions/pushd.fish @@ -1,16 +1,15 @@ function pushd --description 'Push directory to stack' - set -l options 'h/help' - argparse -n pushd --max-args=1 $options -- $argv - or return - - if set -q _flag_help - __fish_print_help pushd - return 0 - end - set -l rot_r set -l rot_l - if set -q argv[1] + + if count $argv >/dev/null + # check for --help + switch $argv[1] + case -h --h --he --hel --help + __fish_print_help pushd + return 0 + end + # emulate bash by checking if argument of form +n or -n if string match -qr '^-[0-9]+$' -- $argv[1] set rot_r (string sub -s 2 -- $argv[1])