File tree Expand file tree Collapse file tree 5 files changed +62
-1
lines changed Expand file tree Collapse file tree 5 files changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,18 @@ if [ $# == 0 ]; then
4
4
exit 3
5
5
fi
6
6
7
+ realpath () {
8
+ if [ -x " $( which realpath ) " ]
9
+ then
10
+ # call the realpath utility if installed
11
+ " $( which realpath ) " " $1 "
12
+ else
13
+ # on MacOS there is no realpath utility on a default installation
14
+ # -> use fallback to perl
15
+ perl -e ' use Cwd "abs_path"; print abs_path(shift)' " $1 "
16
+ fi
17
+ }
18
+
7
19
APP_DIR=$( pwd)
8
20
9
21
if [[ -f " $APP_DIR /.bash_cli" ]]; then
Original file line number Diff line number Diff line change @@ -12,6 +12,18 @@ COLOR_LIGHT_GRAY="\033[37m"
12
12
COLOR_DARK_GRAY=" \033[38m"
13
13
COLOR_NORMAL=" \033[39m"
14
14
15
+ realpath () {
16
+ if [ -x " $( which realpath ) " ]
17
+ then
18
+ # call the realpath utility if installed
19
+ " $( which realpath ) " " $1 "
20
+ else
21
+ # on MacOS there is no realpath utility on a default installation
22
+ # -> use fallback to perl
23
+ perl -e ' use Cwd "abs_path"; print abs_path(shift)' " $1 "
24
+ fi
25
+ }
26
+
15
27
function bcli_resolve_path() {
16
28
realpath " $1 "
17
29
}
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
+ realpath () {
4
+ if [ -x " $( which realpath ) " ]
5
+ then
6
+ # call the realpath utility if installed
7
+ " $( which realpath ) " " $1 "
8
+ else
9
+ # on MacOS there is no realpath utility on a default installation
10
+ # -> use fallback to perl
11
+ perl -e ' use Cwd "abs_path"; print abs_path(shift)' " $1 "
12
+ fi
13
+ }
14
+
3
15
ROOT_DIR=$( dirname " $( realpath " $0 " ) " )
4
16
5
17
# shellcheck source=./bash-cli.inc.sh
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
+ # this file is sourced by /etc/bash_completion.d/* and therefore should not shadow
4
+ # any existing commands in the shell -> add bcli_ prefix to realpath-helper function here
5
+ bcli_realpath () {
6
+ if [ -x " $( which realpath ) " ]
7
+ then
8
+ # call the realpath utility if installed
9
+ " $( which realpath ) " " $1 "
10
+ else
11
+ # on MacOS there is no realpath utility on a default installation
12
+ # -> use fallback to perl
13
+ perl -e ' use Cwd "abs_path"; print abs_path(shift)' " $1 "
14
+ fi
15
+ }
3
16
4
17
function _bash_cli() {
5
18
local root_dir;
6
- root_dir=$( dirname " $( realpath " $( which " ${COMP_WORDS[0]} " ) " ) " )
19
+ root_dir=$( dirname " $( bcli_realpath " $( which " ${COMP_WORDS[0]} " ) " ) " )
7
20
8
21
# shellcheck source=./bash-cli.inc.sh
9
22
. " $root_dir /bash-cli.inc.sh"
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
+ realpath () {
4
+ if [ -x " $( which realpath ) " ]
5
+ then
6
+ # call the realpath utility if installed
7
+ " $( which realpath ) " " $1 "
8
+ else
9
+ # on MacOS there is no realpath utility on a default installation
10
+ # -> use fallback to perl
11
+ perl -e ' use Cwd "abs_path"; print abs_path(shift)' " $1 "
12
+ fi
13
+ }
14
+
3
15
ROOT_DIR=$( dirname " $( realpath " $0 " ) " )
4
16
5
17
# shellcheck source=./bash-cli.inc.sh
You can’t perform that action at this time.
0 commit comments