History

compat/cuda/ptx2c: remove bashism and harden against arbitrary input

Timo Rothenpieler committed 9 years ago

Commit 88896c41 parent f0435bb1 file · +6 −6Browse files

Unified · Split

compat/cuda/ptx2c.sh+6−6
@@ -1,3 +1,5 @@
1#!/bin/sh
2
1# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.3# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
2#4#
3# Permission is hereby granted, free of charge, to any person obtaining a5# Permission is hereby granted, free of charge, to any person obtaining a
@@ -22,15 +24,13 @@ set -e · 18 unmodified lines
22 24
23OUT="$1"25OUT="$1"
24IN="$2"26IN="$2"
25NAME="$(basename "$IN")"27NAME="$(basename "$IN" | sed 's/\..*//')"
26NAME="${NAME/.ptx/}"
27 28
28echo -n "const char ${NAME}_ptx[] = \\" > "$OUT"29printf "const char %s_ptx[] = \\" "$NAME" > "$OUT"
29while read LINE30while read LINE
30do31do
31echo -ne "\n\t\"$LINE\\\n\"" >> "$OUT"32 printf "\n\t\"%s\\\n\"" "$(printf "%s" "$LINE" | sed 's/["\\]/\\&/g')" >> "$OUT"
32done < "$IN"33done < "$IN"
33echo ";" >> "$OUT"34printf ";\n" >> "$OUT"
34 35
35exit 036exit 0
36

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t