summaryrefslogtreecommitdiff
path: root/usr.sbin/btrace
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2020-03-27 09:37:07 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2020-03-27 09:37:07 +0000
commit3cb862645827d1e1687f8c6bb35cdc861008da6a (patch)
treee56b3ff44a77218a7b47237e6fda8ac44aaad338 /usr.sbin/btrace
parentcea14634fd45b0fdfd49a60f8f65e1246c5c8612 (diff)
Skip first line if it starts with '#!'
Diffstat (limited to 'usr.sbin/btrace')
-rw-r--r--usr.sbin/btrace/bt_parse.y8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.sbin/btrace/bt_parse.y b/usr.sbin/btrace/bt_parse.y
index 0be86d1a01b..c17caea9829 100644
--- a/usr.sbin/btrace/bt_parse.y
+++ b/usr.sbin/btrace/bt_parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: bt_parse.y,v 1.9 2020/03/19 15:52:30 mpi Exp $ */
+/* $OpenBSD: bt_parse.y,v 1.10 2020/03/27 09:37:06 mpi Exp $ */
/*
* Copyright (c) 2019 - 2020 Martin Pieuchot <mpi@openbsd.org>
@@ -614,8 +614,10 @@ again:
}
}
- /* skip single line comments */
- if (c == '/' && peek() == '/') {
+ /* skip single line comments and shell magic */
+ if ((c == '/' && peek() == '/') ||
+ (yylval.lineno == 1 && yylval.colno == 1 && c == '#' &&
+ peek() == '!')) {
for (c = lgetc(); c != EOF; c = lgetc()) {
if (c == '\n') {
yylval.lineno++;