busybox_bin=/sbin/busybox # 获取PIPE get_outfd(){ if $busybox_bin ls -l /proc/self/fd/21 | $busybox_bin grep -q 'pipe'; then echo 21 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 " > /proc/self/fd/$OUTFD echo -n -e "ui_print " > /proc/self/fd/$OUTFD fi } ui_print "Iam here!!!"
在Shell脚本中可以使用ui_print可以方便调试Recovery环境运行的Shell脚本,也可以向用户提供关键的日志信息