feat(injections): add printf format strings

This commit is contained in:
ObserverOfTime 2023-08-19 19:28:45 +03:00 committed by Christian Clason
parent 2160b26453
commit 947c43052c
14 changed files with 184 additions and 20 deletions

View file

@ -8,3 +8,28 @@
(heredoc_body) @injection.content
(heredoc_end) @injection.language)
(#downcase! @injection.language))
; printf 'format'
((command
name: (command_name) @_command
. argument: [(string) (raw_string)] @injection.content)
(#eq? @_command "printf")
(#set! injection.language "printf"))
; printf -v var 'format'
((command
name: (command_name) @_command
argument: (word) @_arg
. (_) . argument: [(string) (raw_string)] @injection.content)
(#eq? @_command "printf")
(#eq? @_arg "-v")
(#set! injection.language "printf"))
; printf -- 'format'
((command
name: (command_name) @_command
argument: (word) @_arg
. argument: [(string) (raw_string)] @injection.content)
(#eq? @_command "printf")
(#eq? @_arg "--")
(#set! injection.language "printf"))