11#! /usr/bin/env bash
22
33SCRIPT_DIR=" $( dirname " ${BASH_SOURCE[0]} " ) "
4- BUILDROOT_ABS=" $( realpath " $SCRIPT_DIR /../../buildroot/include" 2> /dev/null || echo " " ) "
4+ BUILDROOT_ABS=" $( realpath " $SCRIPT_DIR /../../buildroot/include" 2> /dev/null || true ) "
55PARSED_ARGS=()
66
77while [[ $# -gt 0 ]]; do
88 case " $1 " in
99 -isystem)
1010 shift
1111 ARG=" $1 "
12- [[ -n " $ARG " ]] && shift || break
13- ARG_ABS=" $( realpath " $ARG " 2> /dev/null || echo " " ) "
14- if [[ -n " $ARG_ABS " && " $ARG_ABS " == " $BUILDROOT_ABS " ]]; then
15- PARSED_ARGS+=(" -I$ARG " )
16- else
17- PARSED_ARGS+=(" -isystem" " $ARG " )
18- fi
12+ shift
13+ ARG_ABS=" $( realpath " $ARG " 2> /dev/null || true) "
14+ [[ " $ARG_ABS " == " $BUILDROOT_ABS " ]] && PARSED_ARGS+=(" -I$ARG " ) || PARSED_ARGS+=(" -isystem" " $ARG " )
1915 ;;
2016 -isystem* )
2117 ARG=" ${1# -isystem} "
2218 shift
23- ARG_ABS=" $( realpath " $ARG " 2> /dev/null || echo " " ) "
24- if [[ -n " $ARG_ABS " && " $ARG_ABS " == " $BUILDROOT_ABS " ]]; then
25- PARSED_ARGS+=(" -I$ARG " )
26- else
27- PARSED_ARGS+=(" -isystem$ARG " )
28- fi
19+ ARG_ABS=" $( realpath " $ARG " 2> /dev/null || true) "
20+ [[ " $ARG_ABS " == " $BUILDROOT_ABS " ]] && PARSED_ARGS+=(" -I$ARG " ) || PARSED_ARGS+=(" -isystem$ARG " )
2921 ;;
3022 * )
3123 PARSED_ARGS+=(" $1 " )
@@ -34,16 +26,13 @@ while [[ $# -gt 0 ]]; do
3426 esac
3527done
3628
37- TARGET=" "
38- if [ -n " $SPC_TARGET " ]; then
39- TARGET=" -target $SPC_TARGET "
40- fi
29+ [[ -n " $SPC_TARGET " ]] && TARGET=" -target $SPC_TARGET " || TARGET=" "
4130
4231output=$( zig cc $TARGET $COMPILER_EXTRA " ${PARSED_ARGS[@]} " 2>&1 )
4332status=$?
4433
45- if [ $status -ne 0 ] && echo " $output " | grep -q " version '.*' in target triple" ; then
46- output=$( echo " $output " | grep -v " version '.*' in target triple" )
34+ if [[ $status -ne 0 ]] && grep -q " version '.*' in target triple" <<< " $output " ; then
35+ output=$( grep -v " version '.*' in target triple" <<< " $output " )
4736 status=0
4837fi
4938
0 commit comments