busybox_bin=/sbin/busybox # 获取PIPE
get_outfd(){
if $busybox_bin ls -l /proc/self/fd/ | $busybox_bin grep -q 'pipe'; then
echo
else
local all_pipe_file=/tmp/all_pipe_file.txt
$busybox_bin ls -l /proc/self/fd/ > $all_pipe_file
$busybox_bin grep 'pipe:' $all_pipe_file | $busybox_bin awk '{print $9}'
fi
} OUTFD=$(get_outfd) # 打印日志
ui_print(){
if $busybox_bin test -n $OUTFD;then
echo -n -e "ui_print $1\n" > /proc/self/fd/$OUTFD
echo -n -e "ui_print\n" > /proc/self/fd/$OUTFD
fi
} ui_print "Iam here!!!"
在Shell脚本中可以使用ui_print可以方便调试Recovery环境运行的Shell脚本,也可以向用户提供关键的日志信息