File tree Expand file tree Collapse file tree 1 file changed +1
-30
lines changed Expand file tree Collapse file tree 1 file changed +1
-30
lines changed Original file line number Diff line number Diff line change 11#! /bin/bash
2- function upto() {
3- local EXPRESSION=" $1 "
4- if [ -z " $EXPRESSION " ]; then
5- echo " A folder expression must be provided." >&2
6- return 1
7- fi
8- if [ " $EXPRESSION " = " /" ]; then
9- cd " /"
10- return 0
11- fi
12- local CURRENT_FOLDER=" $( pwd) "
13- local MATCHED_DIR=" "
14- local MATCHING=true
15-
16- while [ " $MATCHING " = true ]; do
17- if [[ " $CURRENT_FOLDER " =~ " $EXPRESSION " ]]; then
18- MATCHED_DIR=" $CURRENT_FOLDER "
19- CURRENT_FOLDER=$( dirname " $CURRENT_FOLDER " )
20- else
21- MATCHING=false
22- fi
23- done
24- if [ -n " $MATCHED_DIR " ]; then
25- cd " $MATCHED_DIR "
26- return 0
27- else
28- echo " No Match." >&2
29- return 1
30- fi
31- }
2+ function upto() { cd ${PWD%% ${PWD#*/* ([^/])$1 */ } } ; }
323
334# complete upto
345_upto () {
You can’t perform that action at this time.
0 commit comments