Skip to content

Commit

Permalink
compat/cuda/ptx2c: remove bashism and harden against arbitrary input
Browse files Browse the repository at this point in the history
  • Loading branch information
BtbN committed May 15, 2017
1 parent f0435bb commit 88896c4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions compat/cuda/ptx2c.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
Expand All @@ -22,15 +24,13 @@ set -e

OUT="$1"
IN="$2"
NAME="$(basename "$IN")"
NAME="${NAME/.ptx/}"
NAME="$(basename "$IN" | sed 's/\..*//')"

echo -n "const char ${NAME}_ptx[] = \\" > "$OUT"
printf "const char %s_ptx[] = \\" "$NAME" > "$OUT"
while read LINE
do
echo -ne "\n\t\"$LINE\\\n\"" >> "$OUT"
printf "\n\t\"%s\\\n\"" "$(printf "%s" "$LINE" | sed 's/["\\]/\\&/g')" >> "$OUT"
done < "$IN"
echo ";" >> "$OUT"
printf ";\n" >> "$OUT"

exit 0

0 comments on commit 88896c4

Please sign in to comment.