File: fixlibusb_darwin.sh

package info (click to toggle)
golang-github-google-gousb 1.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 944 kB
  • sloc: ansic: 78; sh: 22; makefile: 5
file content (29 lines) | stat: -rwxr-xr-x 740 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
29
#!/bin/bash

function die {
  echo "$@"
  exit 1
}

FILE="$1"
if [[ -z "$FILE" ]]; then
  die "Usage: $0 <path to libusb.h>"
fi

if [[ $(gcc --version | grep -i "llvm") == "" ]]; then
  die "Error: This change is unnecessary unless your gcc uses llvm"
fi

BACKUP="${FILE}.orig"
if [[ -f "$BACKUP" ]]; then
  die "It looks like you've already run this script ($BACKUP exists)"
fi

cp $FILE $BACKUP || die "Could not create backup"

{
  echo 'H'                                  # Turn on error printing
  echo 'g/\[0\].*non-standard/s/\[0\]/[1]/' # Use [1] instead of [0] so the size is unambiguous
  echo 'g/\[.\].*non-standard/p'            # Print the lines changed
  echo 'w'                                  # Write output
} | ed $FILE