tiflolinux.org - GNU Social
  • Login

Bienvenido

  • Public

    • Public
    • Network
    • Groups
    • Popular
    • People

Conversation

Notices

  1. Emacsen (emacsen@emacsen.net)'s status on Sunday, 05-Jun-2022 14:01:36 CEST Emacsen Emacsen

    bash is an unacceptable scripting language

    In conversation Sunday, 05-Jun-2022 14:01:36 CEST from emacsen.net permalink
    • Ekaitz Zárraga 👹 (ekaitz_zarraga@mastodon.social)'s status on Sunday, 05-Jun-2022 14:01:35 CEST Ekaitz Zárraga 👹 Ekaitz Zárraga 👹
      in reply to

      @emacsen those who don't know bash use to say those things 😉

      In conversation Sunday, 05-Jun-2022 14:01:35 CEST permalink
    • Ekaitz Zárraga 👹 (ekaitz_zarraga@mastodon.social)'s status on Sunday, 05-Jun-2022 14:02:12 CEST Ekaitz Zárraga 👹 Ekaitz Zárraga 👹
      in reply to

      @emacsen (it is pretty horrible, yeah, for anything that is not a supershort thing)

      In conversation Sunday, 05-Jun-2022 14:02:12 CEST permalink
    • Emacsen (emacsen@emacsen.net)'s status on Sunday, 05-Jun-2022 14:03:18 CEST Emacsen Emacsen
      in reply to
      • Ekaitz Zárraga 👹

      @ekaitz_zarraga

      I can't get bash to easily let me for loop through files that contain spaces and single quotes.

      In conversation Sunday, 05-Jun-2022 14:03:18 CEST permalink
    • Ekaitz Zárraga 👹 (ekaitz_zarraga@mastodon.social)'s status on Sunday, 05-Jun-2022 14:03:18 CEST Ekaitz Zárraga 👹 Ekaitz Zárraga 👹
      in reply to

      @emacsen for that you need to understand the expansions:

      for i in *; do...

      works perfectly.

      If you try to iterate over `ls`, that's a problem

      In conversation Sunday, 05-Jun-2022 14:03:18 CEST permalink
    • Ekaitz Zárraga 👹 (ekaitz_zarraga@mastodon.social)'s status on Sunday, 05-Jun-2022 14:05:31 CEST Ekaitz Zárraga 👹 Ekaitz Zárraga 👹
      in reply to

      @emacsen the thing is that Bash applies word separation after command substitution, but not after directory expansion. It has a good reason to do that, but if you try to deduce these things from other languages it's pretty hard to do.

      In conversation Sunday, 05-Jun-2022 14:05:31 CEST permalink
    • Ekaitz Zárraga 👹 (ekaitz_zarraga@mastodon.social)'s status on Sunday, 05-Jun-2022 14:07:09 CEST Ekaitz Zárraga 👹 Ekaitz Zárraga 👹
      in reply to

      @emacsen yes, and the directory expansion that the shell does is split properly.
      If you read `man bash` everything is explained there but it's a pretty long file :) (i've read that before)

      Also the book "Pro bash programming" is easy to follow and explains these kind of things

      In conversation Sunday, 05-Jun-2022 14:07:09 CEST permalink
    • Emacsen (emacsen@emacsen.net)'s status on Sunday, 05-Jun-2022 14:07:10 CEST Emacsen Emacsen
      in reply to
      • Ekaitz Zárraga 👹

      @ekaitz_zarraga

      ah right because the shell is already expanding it for you.

      I'm probably going to end up switching this script to be a lua or python script. I just hoped to stay "simple".

      In conversation Sunday, 05-Jun-2022 14:07:10 CEST permalink
    • Emacsen (emacsen@emacsen.net)'s status on Sunday, 05-Jun-2022 14:52:42 CEST Emacsen Emacsen
      in reply to
      • Ekaitz Zárraga 👹

      @ekaitz_zarraga

      The glob helped... but now I get a weird one....

      let's say I do

      for i in "*.txt *.md"; do
      runme $i
      ...

      it goes through the txt files, but then it sends "*.md" to runme!

      In conversation Sunday, 05-Jun-2022 14:52:42 CEST permalink
    • Ekaitz Zárraga 👹 (ekaitz_zarraga@mastodon.social)'s status on Sunday, 05-Jun-2022 14:52:42 CEST Ekaitz Zárraga 👹 Ekaitz Zárraga 👹
      in reply to

      @emacsen i don't think that expansion is correctly thought. What are you trying to expand to?

      In conversation Sunday, 05-Jun-2022 14:52:42 CEST permalink
    • Emacsen (emacsen@emacsen.net)'s status on Sunday, 05-Jun-2022 14:57:33 CEST Emacsen Emacsen
      in reply to
      • Ekaitz Zárraga 👹

      @ekaitz_zarraga

      I have a directory of files, some of which may contain one type, or another type, I want to say "Go through some of these files, but not all of them, only the ones with the extension *.txt and *.md but not, say *.tex

      In conversation Sunday, 05-Jun-2022 14:57:33 CEST permalink
    • Ekaitz Zárraga 👹 (ekaitz_zarraga@mastodon.social)'s status on Sunday, 05-Jun-2022 14:57:33 CEST Ekaitz Zárraga 👹 Ekaitz Zárraga 👹
      in reply to

      @emacsen using that expansion you are combining strings.
      You have to use other kind of expansions...
      ?(*.md|*.txt) or something like that would be better I think.

      Read `man bash` under Pathname Expansion section.
      But you might need to activate glob pattern support in the scripts (in the shell is automatically active)

      In conversation Sunday, 05-Jun-2022 14:57:33 CEST permalink
    • Ekaitz Zárraga 👹 (ekaitz_zarraga@mastodon.social)'s status on Sunday, 05-Jun-2022 15:08:37 CEST Ekaitz Zárraga 👹 Ekaitz Zárraga 👹
      in reply to

      @emacsen the main problem bash has is many of the things it does you can't extrapolate from other languages, so if you don't know it well it's really hard to deduce how to do things...

      In conversation Sunday, 05-Jun-2022 15:08:37 CEST permalink
    • Emacsen (emacsen@emacsen.net)'s status on Sunday, 05-Jun-2022 15:08:38 CEST Emacsen Emacsen
      in reply to
      • Ekaitz Zárraga 👹

      @ekaitz_zarraga

      Thanks! This is already taking me further.

      I still may convert this whole thing to another language but this is helping for sure!

      In conversation Sunday, 05-Jun-2022 15:08:38 CEST permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

tiflolinux.org - GNU Social is a social network, courtesy of tiflolinux.org. It runs on GNU social, version 2.0.1-beta0, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All tiflolinux.org - GNU Social content and data are available under the Creative Commons Attribution 3.0 license.