Dzbj_C3_Key/spi_lcd/run_idf_cmd.sh

26 lines
522 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 保存原始PATH
ORIGINAL_PATH=$PATH
# 移除包含系统clang的路径通常是/usr/bin
MODIFIED_PATH=$(echo $PATH | tr ':' '\n' | grep -v '/usr/bin' | tr '\n' ':')
# 确保路径以冒号结尾
if [[ ! $MODIFIED_PATH =~ :$ ]]; then
MODIFIED_PATH="$MODIFIED_PATH:"
fi
# 输出调试信息
echo "Original PATH: $ORIGINAL_PATH"
echo "Modified PATH: $MODIFIED_PATH"
# 导出修改后的PATH
export PATH=$MODIFIED_PATH
# 执行传入的命令
"$@"
# 恢复原始PATH
export PATH=$ORIGINAL_PATH