-
Notifications
You must be signed in to change notification settings - Fork 167
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
Adjust sed arguments for compatibility with BSD sed #177
Conversation
Makefile
Outdated
@@ -276,7 +276,7 @@ rvfi_preserve_fns=-c_preserve rvfi_set_instr_packet \ | |||
generated_definitions/c/riscv_rvfi_model_$(ARCH).c: $(SAIL_RVFI_SRCS) model/main.sail Makefile | |||
mkdir -p generated_definitions/c | |||
$(SAIL) $(rvfi_preserve_fns) $(SAIL_FLAGS) -O -Oconstant_fold -memo_z3 -c -c_include riscv_prelude.h -c_include riscv_platform.h -c_no_main $(SAIL_RVFI_SRCS) model/main.sail -o $(basename $@) | |||
sed -i -e '/^[[:space:]]*$$/d' $@ | |||
sed -i.bak -e '/^[[:space:]]*$$/d' $@ |
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.
sed -i.bak -e '/^[[:space:]]*$$/d' $@ | |
sed -i '' -e '/^[[:space:]]*$$/d' $@ |
If a zero-length extension is given, no backup will be saved.
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.
I would double check if -i ''
works with GNU sed, I think it may not. -i''
would without the space I think
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.
They're mutually incompatible, unfortunately.
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.
Perhaps you could use perl
to do the same thing? I guess most systems will have it and it might be more portable?
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.
sed -e '/^[[:space:]]*$$/d' $@ > $@.new
mv $@.new $@
is a common portable way to get around the -i importability
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.
On second thoughts using sed and having the backups is probably best.
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.
@jrtc27 's method is the only true POSIX way... in any case, this discussion has convinced me that a comment is necessary to avoid future pain.
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.
I agree.
|
Right, sorry. Brain fart. |
While it looks good to me, we have 5 reviewers already assigned ... anyone willing to approve? |
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.
Please implement Jessica's (completely POSIX-compliant) suggestion.
I've redone it in the redirect and move style, on top of the current HEAD. |
It would be useful if someone with a BSDish system could test it. |
@jrtc27 Could you test on one of your BSD systems? |
Allows for (e.g.) BSD sed, which uses -i differently.
Rebased because the last one became messed up somehow (maybe I did it against the wrong branch?). Also tested it on a CheriBSD machine. |
We don't need the generated backup files, but it appears to be the only
way to be compatible with both GNU and BSD sed.