Changeset 267 for trunk/libjdkmidi/trunk

Show
Ignore:
Timestamp:
01/20/07 21:34:11 (22 months ago)
Author:
jeffk@…
Message:

proper, or at least better sed script quoting rules for variables

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/libjdkmidi/trunk/configure

    r266 r267  
    8787# into a single instance of awk so it is quick. 
    8888# 
    89 # The awk script extracts the variable name as $1, and the part after the '=' as $2.  
     89# The awk script extracts the variable name as var, and the part after the first '=' as val 
    9090# It changes - to _, -- to nothing, converts the string to uppercase, prefixes the 
    91 # variable name with magic_, and prints $2 inside quotes. 
    92 # 
    93 # The result of the awk script is then a multi-line bash script which sets a bunch of environment 
    94 # variables.  This text is then 'eval'd so ultimately the command line arguments show up as vars, 
    95 # with out needing ugly getopt bash extensions for parsing command lines. 
    96  
    97 params=`( 
    98   for i in "$@" 
     91# variable name with magic_, and prints val inside quotes. 
     92# 
     93 
     94for i in "$@" 
    9995  do  
    100     echo $i 
    101   done 
    102 ) | awk '{  line=$0; i = index($0,"="); var = substr(line,0,i); val = substr(line,i+1); gsub("-","_",var); sub("__","",var); print "magic_" toupper(var) "=" "\"" val "\""; }'; ` 
    103  
    104 eval $params 
     96    p=`echo $i | awk '{  line=$0; i = index($0,"="); var = substr(line,0,i-1); val = substr(line,i+1); gsub("-","_",var); sub("__","",var); print "magic_" toupper(var) "=\"" val "\"\n"; }' ` 
     97    eval $p 
     98done 
     99 
     100 
    105101 
    106102# setup all defaults: 
     
    217213 
    218214 
     215 
    219216# extract all environment vars with the "magic_" prefix and save them in vars.sh and GNUmakefile in the appropriate form: 
    220 set | grep '^magic_' | sed "s/'//g" | awk '{ i = index($0,"="); print substr($0,7,i-7) "=\"" substr($0,i+1) "\"" }' >vars.sh 
     217set | grep '^magic_' | sort | sed "s/magic_\(.*\)=[\']*\([^']*\)[\']*/\1=\"\2\"/" >vars.sh 
    221218echo ". \"${magic_PROJECT_TOP_DIR}/project.sh\"" >>vars.sh 
    222 set | grep '^magic_' | sed "s/[\"']//g" | awk '{ i = index($0,"="); print substr($0,7,i-7) "=" substr($0,i+1)  }' >GNUmakefile 
     219set | grep '^magic_' | sort | sed "s/magic_\(.*\)=[\']*\([^']*\)[\']*/\1=\2/" >GNUmakefile 
     220 
     221 
    223222 
    224223echo 'include $(CONFIGURE_DIR)/project.mak' >>GNUmakefile