The above regexp by itself will give a false positive result for constructs like: if [ -n "$LD_LIBRARY_PATH" ]; then export LD_LIBRARY_PATH=$WINELIB:$LD_LIBRARY_PATH else export LD_LIBRARY_PATH=$WINELIB fi