All pastes #254017 Raw Edit

GEILES sed script :)

public shellscript v1 · immutable
#254017 ·published 2006-11-21 11:31 UTC
rendered paste body
        _arraystr=$( $c_ECHO "$_line"| $c_SED -n "            # if we have "varname=" pattern:            # s/^$_sp$_varname$_sp=$_sp/\\)\\(.*\\)$/\"\1\"\n\2/; t found            /^$_sp$_varname$_sp=$_sp/{                # copy the actual pattern (yet the whole line) into HOLD-BUFFER                  h;                # print the stuff BEFORE the VARVALUE:                  s/^\($_sp$_varname$_sp=$_sp\).*/\"\1\"/p;                # and get the original pattern back to continue the match:                  x;                # and throw away the stuff *before* VARVALUE:                  s/^$_sp$_varname$_sp=$_sp\(.*\)$/\1/;                # DBG: print it                  #p;                # look if we have a double-hyphens or single-hyphens or NO-hyphens or ERROR :-)                  /^\"/{                        h;                        s/^\(\"[^\"]*\"\).*$/\\1/p;     # print VARVALUE                        x;                        s/^\"[^\"]*\"\(.*\)$/\\1/;      # throw away VARVALUE                        b print_rest;                   # branch/jump to label print_rest                  }                  /^'/{                        h;                        s/^\('[^']*'\).*$/\\1/p;        # print VARVALUE                        x;                        s/^'[^']*'\(.*\)$/\\1/;         # throw away VARVALUE                        b print_rest;                   # branch/jump to label print_rest                  }                  # else:                        h;                        s/^\([^#]*\).*$/\\1/;           # just keep VARVALUE                        s/[\"\$\`]/\\\&/g;              # escape \" and \$ and \`                        s/.*/\"&\"/p;                   # print VARVALUE                        x;                        s/^[^#]*\(.*\)$/\\1/;           # throw away VARVALUE                        b print_rest;                   # branch/jump to label print_rest                :print_rest                        s/[\"\$\`]/\\\&/g;              # escape \" and \$ and \`                        s/.*/\"&\"/p;                   # print what follows VARVALUE                        b;                              # end this cycle            }        " ); #| sed -e 'N;s:\n: :g;'  -e 'N;s:\n: :g;' );