| OLD | NEW |
| (Empty) |
| 1 #!/bin/bash | |
| 2 # | |
| 3 # This is meant to replicate the behavior of cp, except that it will not fail | |
| 4 # if the source files are not present. Something like | |
| 5 # "cp ${SOURCES} ${DEST} || true" would also have worked except that | |
| 6 # gyp does not allow for specifying || in the action, and the windows | |
| 7 # cygwin envrionment does not include "true" making a script like this the | |
| 8 # least ugly solution. | |
| 9 | |
| 10 SOURCES="" | |
| 11 DESTINATION="" | |
| 12 | |
| 13 # Shift off every argument but the last and consider them the sources. | |
| 14 # It would have probably been easier to put the destination first, but | |
| 15 # this is not too hard and it replicates the argument ordering of cp. | |
| 16 while (( "$#" != 1 )); do | |
| 17 SOURCES="$SOURCES $1" | |
| 18 shift | |
| 19 done | |
| 20 | |
| 21 DESTINATION=$1 | |
| 22 | |
| 23 # Early out if there was not enough parameters to discern a destination. | |
| 24 # Also fail the command because this means we are being invoked incorrectly. | |
| 25 if test -z "$DESTINATION"; then | |
| 26 echo "ERROR: Destination empty." | |
| 27 exit 1 | |
| 28 fi | |
| 29 | |
| 30 # Only try to copy the source file if it exists. It is not an error | |
| 31 # if the input does not exist; we just silently ignore the input. | |
| 32 for i in $SOURCES; do | |
| 33 if test -f $i; then | |
| 34 cp -v -f $i $DESTINATION | |
| 35 fi | |
| 36 done | |
| 37 | |
| 38 # Make sure we always succeed. | |
| 39 exit 0 | |
| OLD | NEW |