startami: strip trailing '})' from amicmd to avoid eval syntax error#332
Open
laurentroque wants to merge 1 commit intopcdshub:masterfrom
Open
startami: strip trailing '})' from amicmd to avoid eval syntax error#332laurentroque wants to merge 1 commit intopcdshub:masterfrom
laurentroque wants to merge 1 commit intopcdshub:masterfrom
Conversation
ZLLentz
reviewed
Jan 31, 2026
|
|
||
| amicmd=$(grep ami_client /reg/g/pcds/dist/pds/"$HUTCH"/scripts/"$CONFIG" | grep -v '#' | awk 'BEGIN { FS = ":" }; { print $4}' | sed s/ami_GUI_path//g | sed s/\'+proxy_cds/"$proxy_cds"/g | sed s:\'+expname:"$EXPNAME"/:g | sed s/+\'//g | sed s/\'\}\)//g) | ||
| # Strip trailing cnf/python artifacts (e.g. "})") so eval doesn't choke | ||
| amicmd=$(printf "%s" "$amicmd" | sed 's/[[:space:]]*[})][})]*$//') |
Member
There was a problem hiding this comment.
Some nitpicky questions, if this works I think it's correct to merge without addressing these.
I'm mostly trying to update my own sed/regex knowledge.
- Why is this a new command using
printfinstead of joining onto the| sedtrain on line 74? - (Conversely, if new commands are preferred for readability, maybe we should unwrap more of them)
- Why
printfwith no formatting overecho? - What's
[[:space:]]*doing in the sed here? Are you expecting e.g.})? Your PR description only mentions}) - It looks like you're using a literal
[})]followed by a[})]*, but in regex we have a + operator for matching 1 or more instances of a symbol. This could have been[})]\+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Strip trailing config-artifact characters (e.g.,
})) from theamicmdstring constructed inscripts/startamibefore it is executed.Motivation and Context
startami -c cxi_0.cnfcould fail with:eval: syntax error near unexpected token ')'On CXI hosts,
amicmdwas being parsed from theami_clientline incxi_0.cnfand could end up with a trailing}), causing bashevalto error. This change sanitizes the constructed command to avoid the syntax error.How Has This Been Tested?
cxi-monitor:/cds/home/i/iroque/programs/engineering_tools/scripts/startami -c cxi_0.cnf(reaches expected restart prompt; no eval syntax error)cxi-control:/cds/home/i/iroque/programs/engineering_tools/scripts/startami -c cxi_0.cnf(successfully launchesonline_ami; no eval syntax error)xcs-control:/cds/home/i/iroque/programs/engineering_tools/scripts/startami(successfully launches online_ami; no eval syntax error)Where Has This Been Documented?
amicmdsanitisation line inscripts/startami.