Query CMake to see if it is out of date for a build.
[SquirrelJME.git] / utils-dev / dirmv.sh
blob58c55c4721b891fd6e8d5fd8e6e0ce8664ae5f91
1 #!/bin/sh
2 # ---------------------------------------------------------------------------
3 # Multi-Phasic Applications: SquirrelJME
4 # Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 # Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
6 # ---------------------------------------------------------------------------
7 # SquirrelJME is under the GNU General Public License v3+, or later.
8 # See license.mkd for licensing and copyright information.
9 # ---------------------------------------------------------------------------
10 # DESCRIPTION: Moves a directory from one location to another within fossil,
11 # potentially merging them
13 # Force C locale
14 export LC_ALL=C
16 # Directory of this script
17 __exedir="$(dirname -- "$0")"
19 # Prints usage
20 __help()
22 echo "Usage: $0 [-x] (src) (dest)" 1>&2
23 echo " -x Do nothing, just print what would be done."
26 # Handle arguments
27 __noop="0"
28 while getopts "x" __arg
30 case $__arg in
32 __noop="1"
36 __help
37 exit 1
39 esac
40 done
42 # Down they go
43 shift $(($OPTIND - 1))
45 # Only two args
46 if [ "$#" -ne "2" ]
47 then
48 __help
49 exit 1
52 # Read source and destination as absolute paths so it can handle recursive
53 # moving
54 __src="$("$__exedir/absolute.sh" "$1")"
55 __dest="$("$__exedir/absolute.sh" "$2")"
57 # Need to cut characters from the source path so it is known where they are
58 __cut="$(expr $(printf '%s' "$__src" | wc -m) + 2)"
60 # Go through each file in the source, only consider files
61 find "$__src" -type f | while read __file
63 # Strip from the source to get the basepath
64 __abs="$("$__exedir/absolute.sh" "$__file")"
65 __basepath="$(echo "$__abs" | cut -c "$__cut-")"
67 # Target file
68 __target="$__dest/$__basepath"
70 # Call other move script to handle this file
71 if [ "$__noop" != 0 ]
72 then
73 "$__exedir/fmv.sh" "-x" "$__abs" "$__target"
74 else
75 "$__exedir/fmv.sh" "$__abs" "$__target"
77 done