GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 05:14:32 JST

  1. Embed this notice
    aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 05:14:32 JST aliss aliss
    in reply to
    • Tosti ?
    • aliss

    @tost so, first: u’re amazing, can you believe i never thought before of doing it like this?

    the var is set after the loop finishes, so you can reuse it later!

    i was approaching it something like (1), where my thought process was: first i query the data, then i switch/case, decide what to do after

    but your approach (2) goes like the following: you make up a list of your own and run queries, if the query fails more things are queried, but if it goes okay you exit it and save it, you’re using the query as a control flow thing, and because the last success value will be stored in the var loop, you can parse with switch/case later! finally, there’s an extra element in the loop list to not always end with one of the true options!

    your (2) is very smart and creative! yes the thought process of it may not be as straightforward as “just query data then parse it”, and you’re using the querying line as something to control the loop but it’s amazing! ???

    it made me realise i barely ever use break statements smol brain :02think:

    thx a lot u’re great :02_cheer:

    (1):

    check_distro() { distro=$( grep -Po "(?<=^ID_LIKE=).+" /etc/os-release || grep -Po "(?<=^ID=).+" /etc/os-release ) case "$distro" in "debian"*) : # do debian-based thing ;; "fedora"*) : # do fedora-based thing ;; *) : # err distro not supported ;; esac }

    (2):

    check_distro2() { for distro in debian fedora error do grep -qe $distro /etc/os-release && break done case "$distro" in "debian"*) : # do debian-based thing ;; "fedora"*) : # do fedora-based thing ;; *) : # err distro not supported ;; esac }
    In conversation Monday, 19-Sep-2022 05:14:32 JST from gnusocial.jp permalink

Feeds

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

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.