Created
October 24, 2011 20:42
-
-
Save errordeveloper/1310168 to your computer and use it in GitHub Desktop.
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
set check = (`echo $argv[2] | tr -s '/'`) | |
set items = (`echo -n $argv[1] \ | |
| tr -s '/' \ | |
| tr -s ':' \ | |
| sed 's/:/\n/g' \ | |
| sed 's/\/$//' \ | |
| awk ' ! x[$0]++' \ | |
| grep -v $check`) | |
echo $items | sed 's/\ /:/g' |
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
## A very primitive version would be this: | |
# echo $argv[1] | grep $argv[2] || echo "${argv[1]}:${argv[2]}" | |
## However it doesn't care to be exact and | |
## the path '/opt/devel/man/' is sort of | |
## the same as '/opt/devel/', hece do this: | |
set mode = 0 | |
set many = 0 | |
set items = (`echo -n $argv[1] \ | |
| tr -s '/' \ | |
| tr -s ':' \ | |
| sed 's/:/\n/g' \ | |
| sed 's/\/$//' \ | |
| awk ' ! x[$0]++'`) | |
## tcsh somewhat changes '\n' to '\ ' so | |
## will have to sed it again if clean-up | |
## is required ... | |
## there is a bit redundancy and we should | |
## probably opt for an extra argument to | |
## avoid this !! | |
set check = (`echo $argv[2] \ | |
| tr -s '/' \ | |
| tr -s ':' \ | |
| sed 's:/$::'`) | |
echo $check | grep -q ':$' && @ mode = $mode + 1 | |
echo $check | grep -q '^:' && @ mode = $mode + 2 | |
if ( $mode != 0 ) then | |
set check = (`echo $check \ | |
| tr -d ':' \ | |
| sed 's:/$::'`) | |
endif | |
#if ( $mode == 0 || $mode == 3 ) then | |
# echo "Append!" | |
#else if ( $mode == 1 ) then | |
# echo "Prepend!" | |
#else if ( $mode == 2 ) then | |
# echo "Append!" | |
#endif | |
# | |
#exit | |
foreach item ( $items ) | |
if ( $item == $check ) @ many ++ | |
end | |
if ( $many == 0 ) then | |
if ( $mode == 0 || $mode == 2 || $mode == 3 ) then | |
set items = ( $items $check ) | |
else if ( $mode == 1 ) then | |
set items = ( $check $items ) | |
endif | |
goto return | |
else # if ( $many >= 1 ) then | |
## probably we want to replace existing item :) | |
goto return | |
endif | |
return: | |
## there appears to be an issue with '.' | |
#echo $items | sed 's/\ \//:\//g' | |
echo $items | sed 's/\ /:/g' |
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
# source /opt/devel/env/cflags-noarch.csh | |
set xde_prefix = /opt/Xmos/ | |
set mp = "source /usr/local/scripts/modpath.csh" | |
set dp = "source /usr/local/scripts/delpath.csh" | |
if ($#argv != "1") then | |
echo "usage: source xmos.csh [version|latest|select]" | |
exit -1 | |
else | |
if ( $?XDE_PATH ) then | |
setenv OLD_XDE_PATH $XDE_PATH | |
endif | |
foreach arg ($argv) | |
switch($arg) | |
case *version*: | |
echo "Please specify just the version string!" | |
exit -1 | |
breaksw | |
case *latest*: | |
set xde_versions = `ls $xde_prefix --sort=time` | |
setenv XDE_PATH "${xde_prefix}/${xde_versions[1]}" | |
echo "XDE $xde_versions[1] found!" | |
unset xde_versions | |
breaksw | |
case *select*: | |
echo "NOT YET IMPLEMENTED!" | |
breaksw | |
default: | |
setenv XDE_PATH "${xde_prefix}/${arg}" | |
if ( -e $XDE_PATH/XDE ) then | |
echo "XDE $arg will be used!" | |
else | |
echo "XDE $arg is not found!" | |
exit -2 | |
endif | |
breaksw | |
endsw | |
end | |
if ( $?OLD_XDE_PATH ) then | |
if ( $OLD_XDE_PATH == $XDE_PATH ) then | |
echo "Version `basename $OLD_XDE_PATH` is in use already!" | |
else | |
echo "Will remove `basename $OLD_XDE_PATH` from the PATH!" | |
setenv PATH `$dp ${PATH} ${OLD_XDE_PATH}` | |
endif | |
endif | |
foreach dir ( $XDE_PATH/*bin* ) | |
setenv PATH `$mp ${PATH} "${dir}/:"` | |
end | |
setenv LD_LIBRARY_PATH "${XDE_PATH}/lib/" | |
setenv XCC_XC_INCLUDE_PATH \ | |
"${XDE_PATH}/target/include:${XDE_PATH}/target/include/gcc" | |
setenv XCC_C_INCLUDE_PATH "${XCC_XC_INCLUDE_PATH}" | |
## FIXME: GCC version string! | |
setenv XCC_CPLUS_INCLUDE_PATH \ | |
"${XCC_XC_INCLUDE_PATH}:${XDE_PATH}/target/include/c++/4.2.1" | |
setenv XCC_CPLUS_INCLUDE_PATH \ | |
"${XCC_CPLUS_INCLUDE_PATH}:${XDE_PATH}/target/include/c++/4.2.1/xcore-xmos-elf" | |
setenv XCC_ASSEMBLER_INCLUDE_PATH "${XCC_XC_INCLUDE_PATH}" | |
setenv XCC_LIBRARY_PATH "${XDE_PATH}/target/lib/" | |
setenv XCC_DEVICE_PATH "${XDE_PATH}/configs/" | |
setenv XCC_EXEC_PREFIX "${XDE_PATH}/libexec/" | |
setenv XMOS_DOC_PATH "${XDE_PATH}/doc/" | |
#else | |
# echo -n "'xde_path' is already set to '${xde_path}', you can " | |
# echo -n '`unset xde_path` and re-source this script!\n' | |
#endif | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment