home.social

#shellprogramming — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #shellprogramming, aggregated by home.social.

  1. @trouble

    I thought there was a difference: "while" evaluates the conditional before the statement; "until" evaluates the conditional after the statement. So "until" executes the statement at least once, but "while" executes the statement zero or more times.

    Now, this may be a Pascal-ism. The construct for "until" put conditional at the end of the statement block. Bash and othet shells might be different.

    @stib

    #Pascal #Bash #ShellProgramming

  2. @trouble

    I thought there was a difference: "while" evaluates the conditional before the statement; "until" evaluates the conditional after the statement. So "until" executes the statement at least once, but "while" executes the statement zero or more times.

    Now, this may be a Pascal-ism. The construct for "until" put conditional at the end of the statement block. Bash and othet shells might be different.

    @stib

    #Pascal #Bash #ShellProgramming

  3. @trouble

    I thought there was a difference: "while" evaluates the conditional before the statement; "until" evaluates the conditional after the statement. So "until" executes the statement at least once, but "while" executes the statement zero or more times.

    Now, this may be a Pascal-ism. The construct for "until" put conditional at the end of the statement block. Bash and othet shells might be different.

    @stib

    #Pascal #Bash #ShellProgramming

  4. @trouble

    I thought there was a difference: "while" evaluates the conditional before the statement; "until" evaluates the conditional after the statement. So "until" executes the statement at least once, but "while" executes the statement zero or more times.

    Now, this may be a Pascal-ism. The construct for "until" put conditional at the end of the statement block. Bash and othet shells might be different.

    @stib

    #Pascal #Bash #ShellProgramming

  5. @trouble

    I thought there was a difference: "while" evaluates the conditional before the statement; "until" evaluates the conditional after the statement. So "until" executes the statement at least once, but "while" executes the statement zero or more times.

    Now, this may be a Pascal-ism. The construct for "until" put conditional at the end of the statement block. Bash and othet shells might be different.

    @stib

    #Pascal #Bash #ShellProgramming

  6. #textbasedgames #ShellProgramming #bashgames considering to upload #CastleOfDoom on #github just in case anyone could find it interesting. Has been 3 weeks of frantically coding what now feels like a #DnD session on your linux terminal.

  7. #textbasedgames #ShellProgramming #bashgames considering to upload #CastleOfDoom on #github just in case anyone could find it interesting. Has been 3 weeks of frantically coding what now feels like a #DnD session on your linux terminal.

  8. #textbasedgames #ShellProgramming #bashgames considering to upload #CastleOfDoom on #github just in case anyone could find it interesting. Has been 3 weeks of frantically coding what now feels like a #DnD session on your linux terminal.

  9. #textbasedgames #ShellProgramming #bashgames considering to upload #CastleOfDoom on #github just in case anyone could find it interesting. Has been 3 weeks of frantically coding what now feels like a #DnD session on your linux terminal.

  10. #textbasedgames #ShellProgramming
    Races are in! Plus second and third floor finished too! I also rewrote the random generation code and put all of it in a big script that basically throws dices behing the Dungeon Master's screen xD calculating and generating monsters, loot, items, traps and secrets. Awesome.

  11. #textbasedgames #ShellProgramming
    Races are in! Plus second and third floor finished too! I also rewrote the random generation code and put all of it in a big script that basically throws dices behing the Dungeon Master's screen xD calculating and generating monsters, loot, items, traps and secrets. Awesome.

  12. #textbasedgames #ShellProgramming
    Races are in! Plus second and third floor finished too! I also rewrote the random generation code and put all of it in a big script that basically throws dices behing the Dungeon Master's screen xD calculating and generating monsters, loot, items, traps and secrets. Awesome.

  13. #textbasedgames #ShellProgramming
    Races are in! Plus second and third floor finished too! I also rewrote the random generation code and put all of it in a big script that basically throws dices behing the Dungeon Master's screen xD calculating and generating monsters, loot, items, traps and secrets. Awesome.

  14. #textbasedgames #ShellProgramming #CastleOfDoom traps! There are hidden traps! ...And that adds another little bit of fun to this game. Now I have to write the code to have Races in the game. There will be only the 3 major ones, Humans, Dwarves and Elves. First floor is completely written... 24 more to go. Plus some levels below the ground. A cellar and a cemetery for sure.
    Still a long road ahead, but the more complete the game's engine is, the more I can redirect on writing levels.

  15. #textbasedgames #ShellProgramming #CastleOfDoom traps! There are hidden traps! ...And that adds another little bit of fun to this game. Now I have to write the code to have Races in the game. There will be only the 3 major ones, Humans, Dwarves and Elves. First floor is completely written... 24 more to go. Plus some levels below the ground. A cellar and a cemetery for sure.
    Still a long road ahead, but the more complete the game's engine is, the more I can redirect on writing levels.

  16. #textbasedgames #ShellProgramming #CastleOfDoom traps! There are hidden traps! ...And that adds another little bit of fun to this game. Now I have to write the code to have Races in the game. There will be only the 3 major ones, Humans, Dwarves and Elves. First floor is completely written... 24 more to go. Plus some levels below the ground. A cellar and a cemetery for sure.
    Still a long road ahead, but the more complete the game's engine is, the more I can redirect on writing levels.

  17. #textbasedgames #ShellProgramming #CastleOfDoom traps! There are hidden traps! ...And that adds another little bit of fun to this game. Now I have to write the code to have Races in the game. There will be only the 3 major ones, Humans, Dwarves and Elves. First floor is completely written... 24 more to go. Plus some levels below the ground. A cellar and a cemetery for sure.
    Still a long road ahead, but the more complete the game's engine is, the more I can redirect on writing levels.

  18. #textbasedgames #ShellProgramming #CastleOfDoom is going good. Healing potions have been added, and more magic items. Character creation is growing in options and it's feeling more immersive.
    Plus a number of temporary exported functions that will be actions in the game, such as get_loot, get_items, clean (for getting rid of the monsters' corpses... If you want, or just leave them there piling up)
    More work added on randomization of the game.

  19. #textbasedgames #ShellProgramming #CastleOfDoom is going good. Healing potions have been added, and more magic items. Character creation is growing in options and it's feeling more immersive.
    Plus a number of temporary exported functions that will be actions in the game, such as get_loot, get_items, clean (for getting rid of the monsters' corpses... If you want, or just leave them there piling up)
    More work added on randomization of the game.

  20. #textbasedgames #ShellProgramming #CastleOfDoom is going good. Healing potions have been added, and more magic items. Character creation is growing in options and it's feeling more immersive.
    Plus a number of temporary exported functions that will be actions in the game, such as get_loot, get_items, clean (for getting rid of the monsters' corpses... If you want, or just leave them there piling up)
    More work added on randomization of the game.

  21. #textbasedgames #ShellProgramming #CastleOfDoom is going good. Healing potions have been added, and more magic items. Character creation is growing in options and it's feeling more immersive.
    Plus a number of temporary exported functions that will be actions in the game, such as get_loot, get_items, clean (for getting rid of the monsters' corpses... If you want, or just leave them there piling up)
    More work added on randomization of the game.

  22. If a public foss repo offers a foss setup.sh command line script which, step by step, performs the installation / usage steps the repo readme lists for use at the command line to set up/use the code, what trust measures would you insist upon before downloading and before running the setup.sh script at your local command line? Is there a better way of offering an helpful automated but trustworthy than a scary .sh ?

  23. If a public foss repo offers a foss setup.sh command line script which, step by step, performs the installation / usage steps the repo readme lists for use at the command line to set up/use the code, what trust measures would you insist upon before downloading and before running the setup.sh script at your local command line? Is there a better way of offering an helpful automated but trustworthy #Heredoc than a scary .sh ?

    #ShellProgramming #git #security #codeberg #shellscript #bourneshell

  24. If a public foss repo offers a foss setup.sh command line script which, step by step, performs the installation / usage steps the repo readme lists for use at the command line to set up/use the code, what trust measures would you insist upon before downloading and before running the setup.sh script at your local command line? Is there a better way of offering an helpful automated but trustworthy #Heredoc than a scary .sh ?

    #ShellProgramming #git #security #codeberg #shellscript #bourneshell

  25. If a public foss repo offers a foss setup.sh command line script which, step by step, performs the installation / usage steps the repo readme lists for use at the command line to set up/use the code, what trust measures would you insist upon before downloading and before running the setup.sh script at your local command line? Is there a better way of offering an helpful automated but trustworthy #Heredoc than a scary .sh ?

    #ShellProgramming #git #security #codeberg #shellscript #bourneshell

  26. If a public foss repo offers a foss setup.sh command line script which, step by step, performs the installation / usage steps the repo readme lists for use at the command line to set up/use the code, what trust measures would you insist upon before downloading and before running the setup.sh script at your local command line? Is there a better way of offering an helpful automated but trustworthy #Heredoc than a scary .sh ?

    #ShellProgramming #git #security #codeberg #shellscript #bourneshell

  27. Bash's treatment of empty associative arrays when `set -o nounset` is in effect is infuriating.

    Worked around it by putting a bogus value in the array so that it is never empty.

    #Bash #shellProgramming

  28. Bash's treatment of empty associative arrays when `set -o nounset` is in effect is infuriating.

    Worked around it by putting a bogus value in the array so that it is never empty.

    #Bash #shellProgramming

  29. Bash's treatment of empty associative arrays when `set -o nounset` is in effect is infuriating.

    Worked around it by putting a bogus value in the array so that it is never empty.

    #Bash #shellProgramming

  30. Bash's treatment of empty associative arrays when `set -o nounset` is in effect is infuriating.

    Worked around it by putting a bogus value in the array so that it is never empty.

    #Bash #shellProgramming

  31. Bash's treatment of empty associative arrays when `set -o nounset` is in effect is infuriating.

    Worked around it by putting a bogus value in the array so that it is never empty.

    #Bash #shellProgramming

  32. #Shellprogramming skills are pretty portable between #Linux, #BSD, and #macOS, but some of the underpinnings of macOS are non-standard. It helps to remind yourself that macOS is not a standard #BSD #Unix variant; Apple's #Darwin based systems do a lot of embrace-and-extend under the hood. Here's a practical example that comes up often in the enterprise.

    Most #Linux systems export the current user's login name to the LOGNAME environment variable (often via sourcing /etc/profile) and may also export the user's default shell from the user's #GECOS record in /etc/passwd to the preferred shell (set by an application or the user) as the SHELL environment variable. The canonical way to get access to the user's default shell on most Unix-like systems is by parsing /etc/password or another NSS database with the getent utility, e.g. getent passwd "$LOGNAME" | cut -d: -f7.

    There are other means to do this on Linux too, but macOS doesn't provide this common #POSIX compatible userspace utility. Instead, Darwin relies on opendirectory(8) for storing and accessing GECOS records, requiring other tools to retrieve the information. You can query a user's GECOS record on Darwin like so:

    # directly from the Open Directory service, local or remote
    dscl . -read "/Users/$(id -un)" shell | awk '/^shell:/ {print $2}'

    # from the directory service's cache on the local system
    dscacheutil -q user -a uid "$(id -u)" | awk '/^shell:/ {print $2}'

    Be aware that there are other ways to do this, too, but old school utilities like whoami have been deprecated in favor of id -un, and finger as implemented on most systems (e.g. via [x]inetd, or reading various #dotfiles from users' directories locally or over the network) is considered a security risk.

    In containers, especially with non-standard shells, or with centralized #IAM using #LDAP or #ActiveDirectory, you may have to match the local #userID to a remote #LDIF record to before grepping for the data you need. In addition, nsswitch.conf, PAM modules, NIS+, or other less-common data sources may need to be consulted and each will generally have specific utilities for looking up the stored or cached information that is equivalent to what's normally provided in the 7th GECOS field for each user on standard Linux and Unix systems.

    As always, your mileage may vary based on use case or implementation details. On the plus side, problems are rarely insoluble when you know where to dig for a solution!

  33. #Shellprogramming skills are pretty portable between #Linux, #BSD, and #macOS, but some of the underpinnings of macOS are non-standard. It helps to remind yourself that macOS is not a standard #BSD #Unix variant; Apple's #Darwin based systems do a lot of embrace-and-extend under the hood. Here's a practical example that comes up often in the enterprise.

    Most #Linux systems export the current user's login name to the LOGNAME environment variable (often via sourcing /etc/profile) and may also export the user's default shell from the user's #GECOS record in /etc/passwd to the preferred shell (set by an application or the user) as the SHELL environment variable. The canonical way to get access to the user's default shell on most Unix-like systems is by parsing /etc/password or another NSS database with the getent utility, e.g. getent passwd "$LOGNAME" | cut -d: -f7.

    There are other means to do this on Linux too, but macOS doesn't provide this common #POSIX compatible userspace utility. Instead, Darwin relies on opendirectory(8) for storing and accessing GECOS records, requiring other tools to retrieve the information. You can query a user's GECOS record on Darwin like so:

    # directly from the Open Directory service, local or remote
    dscl . -read "/Users/$(id -un)" shell | awk '/^shell:/ {print $2}'

    # from the directory service's cache on the local system
    dscacheutil -q user -a uid "$(id -u)" | awk '/^shell:/ {print $2}'

    Be aware that there are other ways to do this, too, but old school utilities like whoami have been deprecated in favor of id -un, and finger as implemented on most systems (e.g. via [x]inetd, or reading various #dotfiles from users' directories locally or over the network) is considered a security risk.

    In containers, especially with non-standard shells, or with centralized #IAM using #LDAP or #ActiveDirectory, you may have to match the local #userID to a remote #LDIF record to before grepping for the data you need. In addition, nsswitch.conf, PAM modules, NIS+, or other less-common data sources may need to be consulted and each will generally have specific utilities for looking up the stored or cached information that is equivalent to what's normally provided in the 7th GECOS field for each user on standard Linux and Unix systems.

    As always, your mileage may vary based on use case or implementation details. On the plus side, problems are rarely insoluble when you know where to dig for a solution!

  34. #Shellprogramming skills are pretty portable between #Linux, #BSD, and #macOS, but some of the underpinnings of macOS are non-standard. It helps to remind yourself that macOS is not a standard #BSD #Unix variant; Apple's #Darwin based systems do a lot of embrace-and-extend under the hood. Here's a practical example that comes up often in the enterprise.

    Most #Linux systems export the current user's login name to the LOGNAME environment variable (often via sourcing /etc/profile) and may also export the user's default shell from the user's #GECOS record in /etc/passwd to the preferred shell (set by an application or the user) as the SHELL environment variable. The canonical way to get access to the user's default shell on most Unix-like systems is by parsing /etc/password or another NSS database with the getent utility, e.g. getent passwd "$LOGNAME" | cut -d: -f7.

    There are other means to do this on Linux too, but macOS doesn't provide this common #POSIX compatible userspace utility. Instead, Darwin relies on opendirectory(8) for storing and accessing GECOS records, requiring other tools to retrieve the information. You can query a user's GECOS record on Darwin like so:

    # directly from the Open Directory service, local or remote
    dscl . -read "/Users/$(id -un)" shell | awk '/^shell:/ {print $2}'

    # from the directory service's cache on the local system
    dscacheutil -q user -a uid "$(id -u)" | awk '/^shell:/ {print $2}'

    Be aware that there are other ways to do this, too, but old school utilities like whoami have been deprecated in favor of id -un, and finger as implemented on most systems (e.g. via [x]inetd, or reading various #dotfiles from users' directories locally or over the network) is considered a security risk.

    In containers, especially with non-standard shells, or with centralized #IAM using #LDAP or #ActiveDirectory, you may have to match the local #userID to a remote #LDIF record to before grepping for the data you need. In addition, nsswitch.conf, PAM modules, NIS+, or other less-common data sources may need to be consulted and each will generally have specific utilities for looking up the stored or cached information that is equivalent to what's normally provided in the 7th GECOS field for each user on standard Linux and Unix systems.

    As always, your mileage may vary based on use case or implementation details. On the plus side, problems are rarely insoluble when you know where to dig for a solution!

  35. #Shellprogramming skills are pretty portable between #Linux, #BSD, and #macOS, but some of the underpinnings of macOS are non-standard. It helps to remind yourself that macOS is not a standard #BSD #Unix variant; Apple's #Darwin based systems do a lot of embrace-and-extend under the hood. Here's a practical example that comes up often in the enterprise.

    Most #Linux systems export the current user's login name to the LOGNAME environment variable (often via sourcing /etc/profile) and may also export the user's default shell from the user's #GECOS record in /etc/passwd to the preferred shell (set by an application or the user) as the SHELL environment variable. The canonical way to get access to the user's default shell on most Unix-like systems is by parsing /etc/password or another NSS database with the getent utility, e.g. getent passwd "$LOGNAME" | cut -d: -f7.

    There are other means to do this on Linux too, but macOS doesn't provide this common #POSIX compatible userspace utility. Instead, Darwin relies on opendirectory(8) for storing and accessing GECOS records, requiring other tools to retrieve the information. You can query a user's GECOS record on Darwin like so:

    # directly from the Open Directory service, local or remote
    dscl . -read "/Users/$(id -un)" shell | awk '/^shell:/ {print $2}'

    # from the directory service's cache on the local system
    dscacheutil -q user -a uid "$(id -u)" | awk '/^shell:/ {print $2}'

    Be aware that there are other ways to do this, too, but old school utilities like whoami have been deprecated in favor of id -un, and finger as implemented on most systems (e.g. via [x]inetd, or reading various #dotfiles from users' directories locally or over the network) is considered a security risk.

    In containers, especially with non-standard shells, or with centralized #IAM using #LDAP or #ActiveDirectory, you may have to match the local #userID to a remote #LDIF record to before grepping for the data you need. In addition, nsswitch.conf, PAM modules, NIS+, or other less-common data sources may need to be consulted and each will generally have specific utilities for looking up the stored or cached information that is equivalent to what's normally provided in the 7th GECOS field for each user on standard Linux and Unix systems.

    As always, your mileage may vary based on use case or implementation details. On the plus side, problems are rarely insoluble when you know where to dig for a solution!

  36. #Shellprogramming skills are pretty portable between #Linux, #BSD, and #macOS, but some of the underpinnings of macOS are non-standard. It helps to remind yourself that macOS is not a standard #BSD #Unix variant; Apple's #Darwin based systems do a lot of embrace-and-extend under the hood. Here's a practical example that comes up often in the enterprise.

    Most #Linux systems export the current user's login name to the LOGNAME environment variable (often via sourcing /etc/profile) and may also export the user's default shell from the user's #GECOS record in /etc/passwd to the preferred shell (set by an application or the user) as the SHELL environment variable. The canonical way to get access to the user's default shell on most Unix-like systems is by parsing /etc/password or another NSS database with the getent utility, e.g. getent passwd "$LOGNAME" | cut -d: -f7.

    There are other means to do this on Linux too, but macOS doesn't provide this common #POSIX compatible userspace utility. Instead, Darwin relies on opendirectory(8) for storing and accessing GECOS records, requiring other tools to retrieve the information. You can query a user's GECOS record on Darwin like so:

    # directly from the Open Directory service, local or remote
    dscl . -read "/Users/$(id -un)" shell | awk '/^shell:/ {print $2}'

    # from the directory service's cache on the local system
    dscacheutil -q user -a uid "$(id -u)" | awk '/^shell:/ {print $2}'

    Be aware that there are other ways to do this, too, but old school utilities like whoami have been deprecated in favor of id -un, and finger as implemented on most systems (e.g. via [x]inetd, or reading various #dotfiles from users' directories locally or over the network) is considered a security risk.

    In containers, especially with non-standard shells, or with centralized #IAM using #LDAP or #ActiveDirectory, you may have to match the local #userID to a remote #LDIF record to before grepping for the data you need. In addition, nsswitch.conf, PAM modules, NIS+, or other less-common data sources may need to be consulted and each will generally have specific utilities for looking up the stored or cached information that is equivalent to what's normally provided in the 7th GECOS field for each user on standard Linux and Unix systems.

    As always, your mileage may vary based on use case or implementation details. On the plus side, problems are rarely insoluble when you know where to dig for a solution!

  37. In the quest toward setting up my own capsule, I come up against the need for a preprocessor.
    Do I use something sensible that already exists? Of course not! I’m writing a script that will run any lines starting with ‘!’ directly in the shell, verbatim. Whatever is in the $OUT variable after said command is run is fed into the output file at that line.
    It’s called the SOC (Stupidly Over Capable) preprocessor, and it is going to be a disaster.