Results 1 to 8 of 8

Thread: .BAT in "Execute after" pitfall

  1. #1

    Exclamation .BAT in "Execute after" pitfall

    I was using .bat / .sh files instead of makefiles since forever.

    It turns out, lots of my problems were because [Erroneous statement removed] So, if you, say, set an envvar from inside an if () block it fails silently and without warning!

    Cost me tons of headache and pointless debugging due to executables being compiled with wrong keys.

    And all that time I was thinking FPC 3.x was glitchy fecal matter! Which is untrue, as it turns out!
    Last edited by Chebmaster; 20-08-2018 at 07:27 AM.

  2. #2
    I use GCC make and it works like a charm. Even on Windows seems to work quite well. I know make has a lot of options and stuff, but you can still take a big advantage with basic functionality.
    No signature provided yet.

  3. #3
    Update: this was not the case. The problem was with .bat language quirk: if you change an environment variable inside an if () block, the value you read back from it won't change until after that if () block.

  4. #4
    Update: *both* Lazarus and MSEide use custom built-in .BAT interpreters with limited functionality. They do not allow changing envvars once set! They fail silently at that, no warning.
    The only exception as far as I can tell is PATH.

  5. #5
    should have used
    cmd /c build.bat
    instead of
    right from the start.
    Lzarus invoking cmd.exe works perfectly, the script executes as designed finally allowing me to use loops and other advanced syntax.

  6. #6
    This reminds me that I was thinking about drop makefiles from my Pascal projects and use sh/bat/cmd scripts instead. Since I've learned how to do conditionals in bat/cmd files it seems more possible.
    No signature provided yet.

  7. #7
    PGDCE Developer de_jean_7777's Avatar
    Join Date
    Nov 2006
    Bosnia and Herzegovina (Herzegovina)
    Since both sh and cmd have their own quirks, I tend to avoid them. sh is more usable than cmd though. At work I use python instead of either. But personally, I have simple sh/cmd scripts to just build a simple pascal executable which does the rest. With instafpc or so should be a lot easier to make setup/build scripts than with sh/cmd. I've found, especially when one is doing redundant things, that duplicating functionality accross sh or cmd is bothersome.
    Existence is pain

  8. #8
    I always forget that Pascal can be used as a shell script as well. I have to see how does it work on Windows though.
    No signature provided yet.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts