Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
edit (display-shell-version): use "ble/util/print" instead of "echo" …
…(fixup 066ec63)
- Loading branch information
1 parent
a22e145
commit bdb7dd6
Showing
5 changed files
with
232 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/bin/bash | ||
|
||
function ble/function#get-source-and-lineno/.extract { | ||
local command=$1 | ||
if [[ ${FUNCNAME[1]-} == "$_ble_util_function_util" && ${FUNCNAME[2]-} != "$_ble_util_function_util" ]]; then | ||
return 1 | ||
else | ||
if [[ ${FUNCNAME[1]-} == "$_ble_util_function_name" ]]; then | ||
local src=${BASH_SOURCE[1]} | ||
local line=${BASH_LINENO[0]} | ||
echo "$src:$line" >/dev/tty | ||
if [[ -s $src ]]; then | ||
less +"${line}g" "$src" | ||
fi | ||
else | ||
declare -p BASH_SOURCE BASH_LINENO FUNCNAME >/dev/tty | ||
fi | ||
return 0 | ||
fi | ||
} 1>&11 2>&12 | ||
|
||
function ble/function#get-source-and-lineno { | ||
local _ble_util_function_name=$1 | ||
local _ble_util_function_util=$FUNCNAME | ||
if ble/is-function "$_ble_util_function_name"; then | ||
( | ||
declare -ft "$_ble_util_function_name" | ||
builtin trap 'ble/function#get-source-and-lineno/.extract && return 0' DEBUG | ||
"$_ble_util_function_name" | ||
) 11>&1 12>&2 | ||
fi | ||
} | ||
|
||
function ble/function#get-source-and-lineno.impl2 { | ||
local ret unset_extdebug= | ||
if ! shopt -q extdebug; then | ||
unset_extdebug=1 | ||
shopt -s extdebug | ||
fi | ||
ble/util/assign ret "declare -F '$1' &>/dev/null"; local ext=$? | ||
if [[ $unset_extdebug ]]: then | ||
shopt -u extdebug | ||
fi | ||
|
||
if ((ext==0)); then | ||
ret=${ret#*' '} | ||
lineno=${ret%%' '*} | ||
source=${ret#*' '} | ||
fi | ||
return "$ext" | ||
} | ||
|
||
function ble/function#get-source-and-lineno.impl3 { | ||
local ret shopt=$BASHOPTS # 古い bash で使えない | ||
shopt -s extdebug | ||
ble/util/assign ret "declare -F '$1' &>/dev/null"; local ext=$? | ||
[[ :$unset_extdebug: == *:extdebug:* ]] || shopt -u extdebug | ||
|
||
if ((ext==0)); then | ||
ret=${ret#*' '} | ||
lineno=${ret%%' '*} | ||
source=${ret#*' '} | ||
fi | ||
return "$ext" | ||
} | ||
|
||
function ble/function#get-source-and-lineno.impl4 { | ||
local ret ext | ||
if ! shopt -q extdebug; then | ||
shopt -s extdebug | ||
ble/util/assign ret "declare -F '$1' &>/dev/null"; ext=$? | ||
shopt -u extdebug | ||
else | ||
ble/util/assign ret "declare -F '$1' &>/dev/null"; ext=$? | ||
fi | ||
if ((ext==0)); then | ||
ret=${ret#*' '} | ||
lineno=${ret%%' '*} | ||
source=${ret#*' '} | ||
fi | ||
return "$ext" | ||
} | ||
|
||
function ble/function#get-source-and-lineno.impl2a { | ||
local ret unset_extdebug= | ||
shopt -q extdebug || { unset_extdebug=1; shopt -s extdebug; } | ||
ble/util/assign ret "declare -F '$1' &>/dev/null"; local ext=$? | ||
[[ ! $unset_extdebug ]] || shopt -u extdebug | ||
if ((ext==0)); then | ||
ret=${ret#*' '} | ||
lineno=${ret%%' '*} | ||
source=${ret#*' '} | ||
fi | ||
return "$ext" | ||
} | ||
|
||
#ble/function#get-source-and-lineno ble/util/assign | ||
#ble/function#get-source-and-lineno ble/function#get-source-and-lineno | ||
#ble/function#get-source-and-lineno ble/util/is-stdin-ready | ||
#ble/function#get-source-and-lineno ble/util/setexit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
mkdir -p tmp1 | ||
cd tmp1 | ||
touch hello.txt | ||
(cd ..; mv tmp1 tmp2) | ||
save_pwd1=$PWD | ||
echo -n "1 $PWD "; pwd | ||
ls -la | ||
|
||
echo "# cd -L ." | ||
cd -L . | ||
PWD=$save_pwd1 | ||
echo -n "2 $PWD "; pwd | ||
|
||
echo "# cd $save_pwd1" | ||
cd "$save_pwd1" | ||
echo -n "3 $PWD "; pwd | ||
|
||
|
||
cd .. | ||
rm -rf tmp1 tmp2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters