Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Deleting the static library before generating it?
oBFusCATed:
What shell language is this?
Alpha:
Bash, I think (sorry, I am still relatively new to the Linux world, so I am not sure).
I forgot Linux has the option to run under different shells; maybe the most portable option in this situation would be just
--- Code: ---rm -f $static_output
--- End code ---
MortenMacFly:
--- Quote from: Alpha on September 30, 2012, 11:42:50 pm ---Bash, I think (sorry, I am still relatively new to the Linux world, so I am not sure).
I forgot Linux has the option to run under different shells; maybe the most portable option in this situation would be just
--- Code: ---rm -f $static_output
--- End code ---
--- End quote ---
Looks like this needs to become an option, isn't it? Maybe we could deliver something like common shell commands in one place and make use of, if needed. Kind of standard-macros, but some that are always guaranteed to be present and can be configured.
Freem:
--- Quote from: Alpha on September 30, 2012, 11:42:50 pm ---Bash, I think (sorry, I am still relatively new to the Linux world, so I am not sure).
I forgot Linux has the option to run under different shells; maybe the most portable option in this situation would be just
--- Code: ---rm -f $static_output
--- End code ---
--- End quote ---
IIRC, it is a sh script: bash prefer the use of double '[' so it would have been
--- Code: ---if [[ -w $static_output ]]; then rm -f $static_output; fi
--- End code ---
Also, to write "cleaner" code (I think bash is shell compatible, but shell is not bash compatible... need to check. Anyway, I do not know if csh or zsh have compatibility with other shells so...), you could think about using the command test instead of it's shortcut ( "[...]" ) and to finish, use the && operator:
--- Code: --- test -w $static_output && rm -f $static_output
--- End code ---
This results in, at least, faster code ("&&" is faster than "if" said a teacher of mine, and result as an "if" because if first expression is false, the second is not evaluated, like in C and C++. Anyway, I do not really think that it is important here) and as && is probably also in csh (C-shell, so I guess our usual operators works there too ;) ) maybe a more UNIX portable code too.
About the test, I am not sure it is really useful: "man rm" said this for the "-f" option: "Do not prompt for confirmation. Do not write diagnostic messages or modify the exit status in the case of nonexistent operands. Any previous occurrences of the -i option shall be ignored." so if the use of the test is simply to verify that you can delete... just delete, effect will be identical.
But I would not say everything I said is certain: I am still considering myself as a child with linux scripting.
Navigation
[0] Message Index
[*] Previous page
Go to full version