#! /bin/sed -f # Last edited on 2012-05-05 16:09:04 by stolfilocal # This filter does a crude attempt at converting a "csh" script # to a "bash" script. # Many things are not handled and should be fixed by hand, eg. # # * Arrays must be ${foo[@]} instead of ${foo} # * Arrays are indexed from 0 not from 1 # * The "@" builtin becomes $((...)) # * Numeric compares must use -eq, -gt instead of ==, >, etc. # * The $* becomes $@ in most cases # * The -z test means zero length string, not empty file # * The "echo" often needs "1>&2" redirect s:[#][!] */bin/.*csh.*$:#! /bin/bash:g s!\!\1fi!g s!^\([ ]*\)else if\>!\1elif!g s!^\([ ]*\)end\>!\1done!g s![$][#]argv!$#!g s![$]{[#]\([A-Za-z0-9_]*\)}!${#\1[@]}!g s![$]{\([A-Za-z0-9_]*\):e}!${\1##*.}!g s![$]{\([A-Za-z0-9_]*\):r}!${\1%.*}!g s![$]{\([A-Za-z0-9_]*\):t}!${\1##*/}!g s![$]{\([A-Za-z0-9_]*\):h}!${\1%/*}!g