-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use perl instead of sed #63
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
print("file iocEnvVar.template\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a shebang, usage, and copyright notice? |
||
print("{\n"); | ||
print("pattern\n"); | ||
print("{ ENVNAME, ENVVAR, ENVTYPE }\n"); | ||
Comment on lines
+1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a here-doc could reduce the number of quotes and escaped newlines, and I recommend always quoting the argument to print << __END__;
file "iocEnvVar.template" {
pattern { ENVNAME, ENVVAR, ENVTYPE }
__END__ |
||
while(<>) { | ||
$m = s/^EPICS_([A-Z_]*).*/{${1}, EPICS_${1}, epics}/; | ||
print $_ if $m; | ||
} | ||
print("}\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably better to use
$(PERL)
here instead of directly callingperl
This I leave up to you, but I think I would prefer a perl script that does not read from stdin but takes a file as an argument; looking at most of the perl scripts in use in various EPICS modules that seems to be more the more consistent standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on using
$(PERL)
.Most Base build rules that run generator scripts start with
@$(RM) $@
to explicitly delete the target file first, so any errors which result in the script not actually regenerating the output file will trigger an error from GNUmake instead of it just continuing without recreating the file. I guess that's an enhancement request since the original rule didn't do that, but I recommend adding it anyway.Switching from stdin to a filename argument might not need any changes to your Perl code at all, since using
while (<>) { ... }
in Perl inline code automatically opens and parses the files listed in@ARGV
anyway (improve on that, Python!).