File: patch

package info (click to toggle)
findlib 1.9.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,864 kB
  • sloc: ml: 7,800; xml: 3,138; sh: 1,605; makefile: 427
file content (28 lines) | stat: -rwxr-xr-x 864 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /bin/sh

# Usage: patch @VARIABLE@ value [extra-args-for-cygpath]
# Environment variable USE_CYGPATH is honoured.

varname="$1"
varvalue="$2"

if [ "${USE_CYGPATH}" = "1" ]; then
    #varvalue="$(echo "$varvalue" | sed -e 's;/;\\;g')"
    varvalue="$(cygpath -w -l $3 "$varvalue")"
    varvalue="$(echo "$varvalue" | sed -e 's;\\;\\\\\\\\;g;s/;/\\;/g')"
    # e.g. c:\file is transformed to c:\\\\file
else
    case `uname` in
	MINGW*)
	    varvalue="$(echo "$varvalue" | sed -e 's;\\;\\\\\\\\;g')"
	    # Convert the first letter drive to DOS style (naive).
	    # This is necessary because OCaml uses DOS paths even if
	    # run under MSYS.
	    varvalue="$(echo "$varvalue" | sed -e 's;^/\([a-z]\)/;\1:/;g')"
	    ;;
    esac
fi

sed -e 's;'"$varname"';'"$varvalue"';g'
# e.g. c:\\\\file is parsed by sed as c:\\file which is correct for the
# ocaml string