Menu

[0c50c7]: / compute-prefix.sh  Maximize  Restore  History

Download this file

35 lines (32 with data), 879 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
typeset -i rc=0
if (( $# > 0 )); then
bash_loc="$1"
elif [[ -n $SH_PROG ]] ; then
bash_loc=$SH_PROG
else
SH_PROG=${SHELL:-bash}
bash_loc=$($SH_PROG -c 'echo ${SHELL}')
fi
rc=$?
if (( rc != 0 )) ; then
echo >&2 "Something went wrong in getting \$SHELL for $SH_PROG"
exit $rc
fi
if [[ -z $bash_loc ]] ; then
echo >&2 "Something went wrong in setting bash location from \$SHELL for $SH_PROG"
exit 3
fi
# export PATH=/usr/bin:/bin:/sbin
bashdb_main=$(strings $bash_loc | grep bashdb)
if (( $? != 0 )); then
echo >&2 "Something went wrong in finding bashdb location from \$SHELL for $SH_PROG"
exit 4
fi
main_loc=$(dirname $bashdb_main)
# Strip expected suffixes we would find in main_loc:
# In particular <prefix>/share/bashdb/ -> <prefix>
bashdb_loc=${main_loc%/bashdb}
prefix_loc=${bashdb_loc%/share}
echo $prefix_loc
exit 0
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.