Author Topic: Deleting the static library before generating it?  (Read 16215 times)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Deleting the static library before generating it?
« Reply #15 on: September 30, 2012, 08:15:25 pm »
What shell language is this?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Deleting the static library before generating it?
« Reply #16 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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Deleting the static library before generating it?
« Reply #17 on: October 01, 2012, 10:32:19 am »
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
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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Freem

  • Almost regular
  • **
  • Posts: 219
Re: Deleting the static library before generating it?
« Reply #18 on: October 01, 2012, 12:39:39 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

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

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

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.