Skip to content

use macval() instead of manual escaping#52

Closed
kbjarkefur wants to merge 1 commit into
reprun-46from
get_command
Closed

use macval() instead of manual escaping#52
kbjarkefur wants to merge 1 commit into
reprun-46from
get_command

Conversation

@kbjarkefur
Copy link
Copy Markdown
Contributor

@kbjarkefur kbjarkefur commented Jun 17, 2024

Instead of manually escaping strings and using capture without handling _rc, I suggest we are using this: get_command, word(`"`macval(line)'"'). The code in this PR works on all the examples added related to this issues in test file "${tf}/target-1.do".

If this does not solve all cases, lets add those cases to the test file.

@kbjarkefur kbjarkefur requested a review from bbdaniels June 17, 2024 10:49
@bbdaniels
Copy link
Copy Markdown
Contributor

bbdaniels commented Jun 27, 2024

See #47 for an alternative solution to this -- this similarly does not handle unmatched quotes as in:

* Bad comment "

repkit/src/ado/reprun.ado

Lines 283 to 302 in ef67764

// Sanitize that string! -- see d17586d873a978987f34ba2fe536a311107ea58b for more regex
local theline = `"`macval(line)'"'
while regexm(`"`macval(theline)'"',"[\*]") {
local theline = regexr(`"`macval(theline)'"',"[\*]","")
}
while regexm(`"`macval(theline)'"',"\[//]"){
local theline = regexr(`"`macval(theline)'"',"\[//]","")
}
// Identify all commands in line
foreach w in `macval(theline)' {
cap get_command, word(`"`w'"')
if `doflag' == 1 local dofile = "`w'"
if "`r(command)'" == "do" | "`r(command)'" == "run" {
local doflag = 1
}
else local doflag 0
local line_command = "`line_command' `r(command)'"
}
local line_command : list uniq line_command

@kbjarkefur kbjarkefur closed this Jun 27, 2024
@kbjarkefur kbjarkefur deleted the get_command branch June 27, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants