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

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

Conversation

Notices

  1. Embed this notice
    aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 00:26:12 JST aliss aliss
    • Tosti ?
    @tost hi tosti :goldcrystalheart:
    In conversation Monday, 19-Sep-2022 00:26:12 JST from outerheaven.club permalink
    • Hélène likes this.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 00:31:02 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club hawwo aliss

      In conversation Monday, 19-Sep-2022 00:31:02 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 00:37:33 JST aliss aliss
      in reply to
      • Tosti ?
      @tost im writing cursed shell against my will
      In conversation Monday, 19-Sep-2022 00:37:33 JST permalink
      Hélène likes this.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 00:54:58 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club nice
      I'm thinking about cursed shell

      In conversation Monday, 19-Sep-2022 00:54:58 JST permalink
      Hélène likes this.
    • Embed this notice
      Hélène (helene@p.helene.moe)'s status on Monday, 19-Sep-2022 02:15:00 JST Hélène Hélène
      in reply to
      • Tosti ?

      @aliss @tost shouldn’t you use lsb_release

      In conversation Monday, 19-Sep-2022 02:15:00 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 02:15:02 JST aliss aliss
      in reply to
      • Tosti ?

      @tost it’s silly stuff:

      grep -Po "(?<=^ID_LIKE=).+" /etc/os-release || grep -Po "(?<=^ID=).+" /etc/os-release

      i want to match if a distro is debian or is debian based, then it’ll have debian in ID or ID_LIKE vars, so i can switch/case it later (when the distro is debian, the ID_LIKE doesn’t exist)

      but i’d like a way to not match the second pattern if the first one is already, i found the regex on the internet but it’s perl-flavour, and that one doesn’t require multiple -e patterns, therefore twice and ||

      i’d like to combine it to a single call but weather so hot brain melty

      In conversation Monday, 19-Sep-2022 02:15:02 JST permalink
    • Embed this notice
      Hélène (helene@p.helene.moe)'s status on Monday, 19-Sep-2022 02:15:54 JST Hélène Hélène
      in reply to
      • Hélène
      • Tosti ?
      @aliss @tost also i'd avise against doing that, depending on what you're looking for
      In conversation Monday, 19-Sep-2022 02:15:54 JST permalink
    • Embed this notice
      Hélène (helene@p.helene.moe)'s status on Monday, 19-Sep-2022 02:19:41 JST Hélène Hélène
      in reply to
      • Tosti ?
      @aliss @tost i do have it on fedora
      In conversation Monday, 19-Sep-2022 02:19:41 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 02:19:42 JST aliss aliss
      in reply to
      • Hélène
      • Tosti ?
      @helene @tost not present in fedora, what's the most reliable thing to probe for this?
      In conversation Monday, 19-Sep-2022 02:19:42 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 02:20:38 JST aliss aliss
      in reply to
      • Hélène
      • Tosti ?
      @helene @tost yes but it didn't come installed by default on my VM
      In conversation Monday, 19-Sep-2022 02:20:38 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 02:20:39 JST aliss aliss
      in reply to
      • Hélène
      • Tosti ?
      @helene @tost oh, could u develop further?
      In conversation Monday, 19-Sep-2022 02:20:39 JST permalink
      Hélène likes this.
    • Embed this notice
      Hélène (helene@p.helene.moe)'s status on Monday, 19-Sep-2022 02:21:15 JST Hélène Hélène
      in reply to
      • Tosti ?
      @aliss @tost e.g. if you're trying to know what package manager is available, just check for package managers imo
      In conversation Monday, 19-Sep-2022 02:21:15 JST permalink
    • Embed this notice
      marcille_ebooks ??:coffefiedred: (schappi@mk.toast.cafe)'s status on Monday, 19-Sep-2022 02:21:22 JST marcille_ebooks ??:coffefiedred: marcille_ebooks ??:coffefiedred:
      in reply to
      • Hélène
      • Tosti ?

      @helene@p.helene.moe @aliss@outerheaven.club @tost@mk.toast.cafe reminds me of that time that i wanted to know if i can detect the OS package manager because i have a script that checks for missing deps and i was going to make it so it called for the packman to install them :hana_lul:

      In conversation Monday, 19-Sep-2022 02:21:22 JST permalink
      Hélène likes this.
    • Embed this notice
      Hélène (helene@p.helene.moe)'s status on Monday, 19-Sep-2022 02:25:49 JST Hélène Hélène
      in reply to
      • Tosti ?
      @aliss @tost handling every derivative of arch to check for pacman isn't exactly a solution imo, same for every derivative of debian for dpkg/apt or every derivate of rhel/fedora/centos for dnf/yum
      In conversation Monday, 19-Sep-2022 02:25:49 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 02:25:50 JST aliss aliss
      in reply to
      • Hélène
      • Tosti ?
      @helene @tost hmmm didn't understand the example entirely, why the package manager example makes u advise me against doing the distro/distro-flavor detection in that way?
      In conversation Monday, 19-Sep-2022 02:25:50 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 02:26:46 JST aliss aliss
      in reply to
      • Hélène
      • Tosti ?
      • marcille_ebooks ??:coffefiedred:
      @schappi @tost @helene at least u can detect the binaries with: ```command -v apt``` <3

      but testing whether something named that way is the proper package manager or a prank that's more involved..
      In conversation Monday, 19-Sep-2022 02:26:46 JST permalink
      Hélène likes this.
    • Embed this notice
      marcille_ebooks ??:coffefiedred: (schappi@mk.toast.cafe)'s status on Monday, 19-Sep-2022 02:27:16 JST marcille_ebooks ??:coffefiedred: marcille_ebooks ??:coffefiedred:
      in reply to
      • Hélène
      • Tosti ?

      @aliss@outerheaven.club @tost@mk.toast.cafe @helene@p.helene.moe you mean bypassing alias? tosti told me how to do that if that's the case, i can dig it for you :akko_thonk:

      In conversation Monday, 19-Sep-2022 02:27:16 JST permalink
      Hélène likes this.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 02:39:03 JST Tosti ? Tosti ?
      in reply to
      • Hélène

      @helene@p.helene.moe @aliss@outerheaven.club you can have dpkg/apt installed on arch, for example, so that's not that useful either ?

      In conversation Monday, 19-Sep-2022 02:39:03 JST permalink
      Hélène likes this.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 02:39:05 JST Tosti ? Tosti ?
      in reply to
      • Hélène

      @helene@p.helene.moe @aliss@outerheaven.club it's part of redhat-lsb-core which isn't guaranteed to be installed by default

      In conversation Monday, 19-Sep-2022 02:39:05 JST permalink
      Hélène likes this.
    • Embed this notice
      Ukko (fake) (ukko@p.enes.lv)'s status on Monday, 19-Sep-2022 02:39:08 JST Ukko (fake) Ukko (fake)
      in reply to
      • Hélène
      • Tosti ?
      • marcille_ebooks ??:coffefiedred:
      @schappi @tost @aliss @helene Not just alias, someone could put a random binary or shellscript named `apt` in your PATH and you couldn't tell if it's legit.
      In conversation Monday, 19-Sep-2022 02:39:08 JST permalink
      Hélène likes this.
    • Embed this notice
      Hélène (helene@p.helene.moe)'s status on Monday, 19-Sep-2022 02:39:18 JST Hélène Hélène
      in reply to
      • Tosti ?
      @tost @aliss ah i forgot arch is cursed
      In conversation Monday, 19-Sep-2022 02:39:18 JST permalink
    • Embed this notice
      Hélène (helene@p.helene.moe)'s status on Monday, 19-Sep-2022 02:39:37 JST Hélène Hélène
      in reply to
      • Hélène
      • Tosti ?
      @tost @aliss i'd hope people don't do that though
      In conversation Monday, 19-Sep-2022 02:39:37 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 02:39:40 JST aliss aliss
      in reply to
      • Hélène
      • Tosti ?
      @tost @helene so.. the question is, in ur experience as linux sysadmin what is the better way to start probing?
      In conversation Monday, 19-Sep-2022 02:39:40 JST permalink
      Hélène likes this.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 02:39:45 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club why not grep -qe debian /etc/os-release

      In conversation Monday, 19-Sep-2022 02:39:45 JST permalink
      Hélène likes this.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 02:40:23 JST Tosti ? Tosti ?
      in reply to
      • Hélène
      • marcille_ebooks ??:coffefiedred:

      @schappi @aliss@outerheaven.club @helene@p.helene.moe
      curl -Ls toast.cafe/s/util.sh | grep 'hascmd()' -A8hascmd() { for cmd; do cmd=$(command -v "$cmd") if [ -z "$cmd" ] || ! [ -x "$cmd" ]; then return 1 fi done return 0 }

      In conversation Monday, 19-Sep-2022 02:40:23 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 02:40:25 JST aliss aliss
      in reply to
      • Hélène
      • Tosti ?
      @helene @tost cuwsed uwu
      In conversation Monday, 19-Sep-2022 02:40:25 JST permalink
      Hélène likes this.
    • Embed this notice
      Ukko (fake) (ukko@p.enes.lv)'s status on Monday, 19-Sep-2022 02:42:02 JST Ukko (fake) Ukko (fake)
      in reply to
      • Hélène
      • Tosti ?
      @tost @aliss @helene You could give pacman a priority if it's detected first :D
      In conversation Monday, 19-Sep-2022 02:42:02 JST permalink
      Hélène likes this.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 02:43:21 JST Tosti ? Tosti ?
      in reply to
      • Hélène
      • Ukko (fake)

      @ukko@p.enes.lv @aliss@outerheaven.club @helene@p.helene.moe you can have a pacman binary on debian

      In conversation Monday, 19-Sep-2022 02:43:21 JST permalink
      Hélène likes this.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 02:43:28 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club I would do probes like thatif grep -qe debian /etc/os-release; then # debian elif grep -qe fedora /etc/os-release; then # fedora # keep going this way else fi
      or as a shorthandfor myid in debian fedora whatever; do grep -qe $myid /etc/os-release && break done # switch case on $myid, or empty

      In conversation Monday, 19-Sep-2022 02:43:28 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 02:43:29 JST aliss aliss
      in reply to
      • Tosti ?
      @tost yes but i need to grab the value from ID or ID_LIKE because im also probing for other families (like fedora-based)
      In conversation Monday, 19-Sep-2022 02:43:29 JST permalink
    • Embed this notice
      Ukko (fake) (ukko@p.enes.lv)'s status on Monday, 19-Sep-2022 02:45:02 JST Ukko (fake) Ukko (fake)
      in reply to
      • Hélène
      • Tosti ?
      @tost @aliss @helene alright if conflicting package managers are detected, error out and force the user to select it manually
      In conversation Monday, 19-Sep-2022 02:45:02 JST permalink
      Hélène likes this.
    • Embed this notice
      Ukko (fake) (ukko@p.enes.lv)'s status on Monday, 19-Sep-2022 02:45:07 JST Ukko (fake) Ukko (fake)
      in reply to
      • Hélène
      • Tosti ?
      • Ukko (fake)
      @tost @aliss @helene If you're gonna install emerge, pacman, apt, and nix on your FreeBSD, you can deal with an extra commandline argument
      In conversation Monday, 19-Sep-2022 02:45:07 JST permalink
      Hélène likes this.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 02:48:54 JST Tosti ? Tosti ?
      in reply to
      • Hélène
      • Ukko (fake)

      @ukko@p.enes.lv @aliss@outerheaven.club @helene@p.helene.moe
      the standard way is
      you give a flag to set id
      then after getopts if it's not set, you do detection
      and I'd recommend doing detection as I mentioned :nko_3c:

      In conversation Monday, 19-Sep-2022 02:48:54 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 03:53:56 JST aliss aliss
      in reply to
      • Tosti ?
      @tost aaaa that's another way to solve it! skipping the grabbing the value entirely! :celredcrystalheart:
      In conversation Monday, 19-Sep-2022 03:53:56 JST permalink
      Hélène likes this.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 03:56:58 JST Tosti ? Tosti ?
      in reply to
      • Hélène
      • marcille_ebooks ??:coffefiedred:

      @aliss@outerheaven.club @schappi@mk.toast.cafe @helene@p.helene.moe
      mine is like this so I can pass it a list and it only returns 0 if they all exist
      otherwise you can jus do [ -x "$(command -v \"$1\")" ]

      In conversation Monday, 19-Sep-2022 03:56:58 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 03:57:00 JST aliss aliss
      in reply to
      • Hélène
      • Tosti ?
      • marcille_ebooks ??:coffefiedred:

      @tost @schappi @helene

      funnily i had a very similar looking function in my own shell lib..

      has() { _cmd=$(command -v "$1") 2>/dev/null || return 1 [ -x "$_cmd" ] || return 1 }

      the earth (shell) is round truly

      In conversation Monday, 19-Sep-2022 03:57:00 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 05:14:30 JST aliss aliss
      in reply to
      • Tosti ?

      @tost you’re right my bad!

      (3)

      check_distro3() { 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:30 JST permalink
      Hélène likes this.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 05:14:31 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club you can skip the *s in 2, and also the quotes all over (because you control the input)

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

      @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 permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 05:14:33 JST aliss aliss
      in reply to
      • Tosti ?
      @tost a i see you explained below also, still i will explain later im so excited aaaaaa
      In conversation Monday, 19-Sep-2022 05:14:33 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 05:14:35 JST aliss aliss
      in reply to
      • Tosti ?
      @tost omg i just realised in the shower that is genius!!!!
      lemme have dinner and i will explain im so!!!
      In conversation Monday, 19-Sep-2022 05:14:35 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 05:14:36 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club no, actually

      In conversation Monday, 19-Sep-2022 05:14:36 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 05:14:37 JST aliss aliss
      in reply to
      • Tosti ?
      @tost the switch case would have to be inside the loop right?
      In conversation Monday, 19-Sep-2022 05:14:37 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 05:19:00 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club enjoy and have fun :nko_3c:

      In conversation Monday, 19-Sep-2022 05:19:00 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 05:19:07 JST aliss aliss
      in reply to
      • Tosti ?
      @tost u're so smart tosti h o w i've put many hours into shell when i grow up i want to be smart like u,,
      In conversation Monday, 19-Sep-2022 05:19:07 JST permalink
      Hélène likes this.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 06:15:24 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club it's not super relevant because it's small N and the files in question will get cached tbh

      In conversation Monday, 19-Sep-2022 06:15:24 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 06:15:25 JST aliss aliss
      in reply to
      • Tosti ?
      @tost i have to confess, while your solution is 19 chars less..
      mine is 84 syscalls more efficient.. :acat_hearteyes: (only in fedora, in debian is only 1 syscall more efficient): https://pastebin.com/kn4tLtEX
      In conversation Monday, 19-Sep-2022 06:15:25 JST permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: pastebin.com
        # Straces## Debian```consoledebian-gnu-linux-11:~/Documents$ sudo stra - Pastebin.com
        Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 06:15:34 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club I've been a distrodev ptsd voice

      In conversation Monday, 19-Sep-2022 06:15:34 JST permalink
      Hélène likes this.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 06:17:39 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club older everything
      can't take advantage of newer glibc stuff, or newer coreutils optimizations, or stuff like readfile, etc

      In conversation Monday, 19-Sep-2022 06:17:39 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 06:17:40 JST aliss aliss
      in reply to
      • Tosti ?
      @tost oh, maybe u could shed me light into a question i have.. why fedora and debian syscall's total numbers are so different even for the same script?
      In conversation Monday, 19-Sep-2022 06:17:40 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 06:17:41 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club the short version is
      if the file you're reading is under 4kb, reading it many times over is "free", especially if you're doing it with the same utility

      In conversation Monday, 19-Sep-2022 06:17:41 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 06:17:42 JST aliss aliss
      in reply to
      • Tosti ?
      @tost im sorry master i always tend to do, i'll try to be better apprentice next time
      In conversation Monday, 19-Sep-2022 06:17:42 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 06:17:43 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club basically "don't worry about performance in cases like this"

      In conversation Monday, 19-Sep-2022 06:17:43 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 06:17:43 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club it depends tm tbh

      In conversation Monday, 19-Sep-2022 06:17:43 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 06:17:44 JST aliss aliss
      in reply to
      • Tosti ?
      @tost
      In conversation Monday, 19-Sep-2022 06:17:44 JST permalink

      Attachments


      1. https://outerheaven.club/media/b4b77d97-0304-4ad9-b258-e4a67c80ce3d/image.png
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 06:17:44 JST aliss aliss
      in reply to
      • Tosti ?
      @tost so debian is not using newer glibc stuff therefore less syscalls?
      In conversation Monday, 19-Sep-2022 06:17:44 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 06:59:08 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club it may be shorter, but is it more concise and readable? ?♀️

      In conversation Monday, 19-Sep-2022 06:59:08 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 06:59:09 JST aliss aliss
      in reply to
      • Tosti ?

      @tost tosti tosti tosti i achieved to make mine shorter and beat yours for 18 characters ????

      mine:

      #!/bin/sh check_distro() { distro=$(sed -n 's/^\(ID\|ID_LIKE\)= *\([^ ]*\) */\2/p' /etc/os-release) case $distro in debian) : # do debian-based thing ;; fedora) : # do fedora-based thing ;; *) : # err distro not supported ;; esac } check_distro

      yours:

      #!/bin/sh check_distro() { 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 } check_distro
      In conversation Monday, 19-Sep-2022 06:59:09 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 06:59:11 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club it's just basic caching stuff tbh
      4k basically means it'll fit in a page (and thus is guaranteed to get cached by vfs

      In conversation Monday, 19-Sep-2022 06:59:11 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 06:59:11 JST aliss aliss
      in reply to
      • Tosti ?
      @tost ah thx

      also, when running the tests i first noticed that because in yours debian came first of course some additional syscalls would be in place to test for the first grep, therefore i did `for i in fedora debian...` etc to make it fair
      In conversation Monday, 19-Sep-2022 06:59:11 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 06:59:12 JST aliss aliss
      in reply to
      • Tosti ?
      @tost i had no idea about this where can i read more about it :02think:
      In conversation Monday, 19-Sep-2022 06:59:12 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Tuesday, 20-Sep-2022 20:50:32 JST Tosti ? Tosti ?
      in reply to
      • some fedifriend

      @samgai@vocalounge.cafe @aliss@outerheaven.club mmm that's not a bad point, but that's a very meh way of getting a subshell
      at that point I'd just do( . /etc/os-release; echo $ID; echo $ID_LIKE; ) | grep -qxe debiansimple substring does carry less weirdness potential though, and generally speaking should be fine in this case, imo

      In conversation Tuesday, 20-Sep-2022 20:50:32 JST permalink
      Hélène likes this.
    • Embed this notice
      some fedifriend (samgai@vocalounge.cafe)'s status on Tuesday, 20-Sep-2022 20:50:33 JST some fedifriend some fedifriend
      in reply to
      • Tosti ?

      @tost @aliss If you're not worried about the file containing malware (which an OS-defined file hopefully shouldn't), you can do:

      sh -c '. /etc/os-release; echo $ID; echo $ID_LIKE' | grep -qxe debian

      In conversation Tuesday, 20-Sep-2022 20:50:33 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Tuesday, 20-Sep-2022 20:50:34 JST Tosti ? Tosti ?
      in reply to
      • some fedifriend

      @samgai@vocalounge.cafe @aliss@outerheaven.club writing a serious parser is lame, I would never do it
      t. patok author

      In conversation Tuesday, 20-Sep-2022 20:50:34 JST permalink
    • Embed this notice
      some fedifriend (samgai@vocalounge.cafe)'s status on Tuesday, 20-Sep-2022 20:50:36 JST some fedifriend some fedifriend
      in reply to
      • Tosti ?

      @tost @aliss Please don't do substring matches on data that has a well-defined structure... That's how we wound up with the mess that is HTTP User-Agent, with browser extensions breaking upon the browser reaching version 100, etc...

      In conversation Tuesday, 20-Sep-2022 20:50:36 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Wednesday, 21-Sep-2022 09:35:25 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club that's not bad, except you have a mismatch between ID and dist
      I'd probably do something likegetopts 'd...' # ... d) dist="$OPTARG" ;; # .... if [ -z "$dist" ] && [ -f /etc/os-release ]; then . /etc/os-release dist="${ID_LIKE:-$ID}" fiAs one side-note, if this was bash, you could avoid additional leakage using my upvar by slapping the then into a subshell that you source ?

      In conversation Wednesday, 21-Sep-2022 09:35:25 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Wednesday, 21-Sep-2022 09:35:26 JST aliss aliss
      in reply to
      • Tosti ?

      @tost what about

      if [ -z "$ID" ] && [ -f /etc/os-release ] then . /etc/os-release dist="${ID_LIKE:-$ID}" fi

      only when var doesn’t exist and when file exists, then source the file, then assign family to var

      In conversation Wednesday, 21-Sep-2022 09:35:26 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Wednesday, 21-Sep-2022 09:35:27 JST aliss aliss
      in reply to
      • Tosti ?
      @tost aaaaaa i knew my posix after all :shiro_wink:
      In conversation Wednesday, 21-Sep-2022 09:35:27 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Wednesday, 21-Sep-2022 09:35:29 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club no no you got it right
      I just remembered them being reversed ^^;;

      In conversation Wednesday, 21-Sep-2022 09:35:29 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Wednesday, 21-Sep-2022 09:35:30 JST Tosti ? Tosti ?
      in reply to
      • some fedifriend

      @aliss@outerheaven.club @samgai@vocalounge.cafe
      https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02
      :- means substitute always
      - means don't substitute if it's set but null
      this way if it's missing but has been explicitly set to null, it'll hit the breaks :^)
      (I actually remebered it being the opposite so do ignore this piece of advice)

      In conversation Wednesday, 21-Sep-2022 09:35:30 JST permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: pubs.opengroup.org
        Shell Command Language
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Wednesday, 21-Sep-2022 09:35:30 JST aliss aliss
      in reply to
      • Tosti ?

      @tost my brain melty a bit with the way you phrased it! haha

      i was familiar with this section and i didn’t use - because if it’s set to empty string it wont expand to the second element, and i wanted that so i used :- (if i got it correctly)

      if i’ve got it wrong could u clarify / develop further? <33

      In conversation Wednesday, 21-Sep-2022 09:35:30 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Wednesday, 21-Sep-2022 09:35:32 JST aliss aliss
      in reply to
      • Tosti ?
      • some fedifriend
      @tost @samgai what only - would mean?
      In conversation Wednesday, 21-Sep-2022 09:35:32 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Wednesday, 21-Sep-2022 09:35:34 JST Tosti ? Tosti ?
      in reply to
      • some fedifriend

      @aliss@outerheaven.club @samgai@vocalounge.cafe consider using - instead of :-

      In conversation Wednesday, 21-Sep-2022 09:35:34 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Wednesday, 21-Sep-2022 09:35:35 JST Tosti ? Tosti ?
      in reply to
      • some fedifriend

      @aliss@outerheaven.club @samgai@vocalounge.cafe yes, but only because os-release is explicitly shell-compatible
      I would maybe do it in a subshell but either way, it's fine
      don't forget to do something like ${ID=$ID_LIKE} or whatever

      In conversation Wednesday, 21-Sep-2022 09:35:35 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Wednesday, 21-Sep-2022 09:35:35 JST aliss aliss
      in reply to
      • Tosti ?
      • some fedifriend

      @tost @samgai yay we found an even shorter solution! another win for lateral thinking :meow_party:

      i learned a lot through the way, all thanks to you :02superblush:

      don’t forget to do something like ${ID=$ID_LIKE}

      hmmm yea you wrote "${ID:=$ID_LIKE}" originally i’d write "${ID_LIKE:-$ID}“ ie: if ID_LIKE exists use that, bc is the family, if not use ID, because that will be “mommy distro”, and the :- because i don’t want to override ID_LIKE

      In conversation Wednesday, 21-Sep-2022 09:35:35 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Wednesday, 21-Sep-2022 09:35:37 JST aliss aliss
      in reply to
      • Tosti ?
      • some fedifriend
      @tost @samgai true
      tosti do you prefer this source+case over your grep version?
      In conversation Wednesday, 21-Sep-2022 09:35:37 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Wednesday, 21-Sep-2022 09:35:38 JST Tosti ? Tosti ?
      in reply to
      • some fedifriend

      @aliss@outerheaven.club @samgai@vocalounge.cafe os-release is a system level file with typically correct permissions (0:0 and 644) so anytime a malicious actor can edit it, it's because they have effective root permissions
      at which point uh... what are you worried they're going to do that they can't ALREADY do?

      In conversation Wednesday, 21-Sep-2022 09:35:38 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Wednesday, 21-Sep-2022 09:35:39 JST aliss aliss
      in reply to
      • Tosti ?
      • some fedifriend
      @tost @samgai initially i didn't think to source it directly because this post made me worried
      https://unix.stackexchange.com/a/433245
      In conversation Wednesday, 21-Sep-2022 09:35:39 JST permalink

      Attachments


    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Wednesday, 21-Sep-2022 09:35:40 JST Tosti ? Tosti ?
      in reply to
      • some fedifriend

      @samgai@vocalounge.cafe @aliss@outerheaven.club if so then you could just do. /etc/os-release case "${ID:=$ID_LIKE}" in debian) ;; *) exit 1 ;; esac

      In conversation Wednesday, 21-Sep-2022 09:35:40 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Wednesday, 21-Sep-2022 09:35:41 JST Tosti ? Tosti ?
      in reply to
      • some fedifriend

      @samgai@vocalounge.cafe @aliss@outerheaven.club is os-release actually defined to be shell syntax?
      I'm under the impression that it's defined to be systemd-compatible ini, which means it could just be completely broken while being "normal" and "expected"

      In conversation Wednesday, 21-Sep-2022 09:35:41 JST permalink
    • Embed this notice
      some fedifriend (samgai@vocalounge.cafe)'s status on Wednesday, 21-Sep-2022 09:35:42 JST some fedifriend some fedifriend
      in reply to
      • Tosti ?

      @aliss @tost That looks reasonable to me. It might give you some false negatives, depending on the particular subset of shell syntax that /etc/os-release wants to use.

      In conversation Wednesday, 21-Sep-2022 09:35:42 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Wednesday, 21-Sep-2022 09:35:43 JST aliss aliss
      in reply to
      • Tosti ?
      • some fedifriend
      @samgai @tost would the first one be problematic with substring matches on data that has a well-defined structure too?
      https://outerheaven.club/notice/ANha4e6GZvHvYwOmWW
      In conversation Wednesday, 21-Sep-2022 09:35:43 JST permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: outerheaven.club
        aliss (@aliss@outerheaven.club)
        @tost tosti tosti tosti i achieved to make mine shorter and beat yours for 18 characters ????mine:#!/bin/sh check_distro() { distro=$(sed -n 's/^\(ID\|ID_LIKE\)= *\([^ ]*\) */\2/p' /etc/os-relea...
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Wednesday, 21-Sep-2022 09:39:43 JST aliss aliss
      in reply to
      • Tosti ?
      @tost aaaa ic u were trying to provide cli through getopts and grabbing it with OPTARG, i was confused at first

      oki resty well <3
      In conversation Wednesday, 21-Sep-2022 09:39:43 JST permalink
      Hélène likes this.
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Wednesday, 21-Sep-2022 09:39:44 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club my approach means users can just set it themselves :nko_3c:
      and then uses dist
      I'm tired now though :apensive:
      messed with unicode all day

      In conversation Wednesday, 21-Sep-2022 09:39:44 JST permalink
      Hélène likes this.
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Wednesday, 21-Sep-2022 09:39:45 JST aliss aliss
      in reply to
      • Tosti ?

      @tost

      if you use $ID after that point, then you lose our on your ID_LIKE preference .

      you mean that if i were to change $ID afterwards and run the conditional again then i’d lose the initial value?

      if you use $dist after that point, it’s not going to be set if ID is already set .

      you’re right, so more code, another conditional, would be needed like: if $ID is already set, then put it to dist=.. which would mask the family in a context where the user already has the environ with $ID=kali, then my code wouldn’t do anything still hmmmm :02think:

      mebbe like this?:

      if [ -z "$ID_LIKE" ] && [ -f /etc/os-release ] then . /etc/os-release else return 1 fi dist="${ID_LIKE:-$ID}"
      In conversation Wednesday, 21-Sep-2022 09:39:45 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Wednesday, 21-Sep-2022 09:39:46 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club no you don't understand
      you're setting "dist"
      if you use $ID after that point, then you lose our on your ID_LIKE preference
      if you use $dist after that point, it's not going to be set if ID is already set

      In conversation Wednesday, 21-Sep-2022 09:39:46 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Wednesday, 21-Sep-2022 09:39:47 JST aliss aliss
      in reply to
      • Tosti ?

      @tost yes because if ID is empty then we need to source os-release but if it’s not empty then we can assume it was sourced already

      did it like this to not do it like "${ID:-$([ -f /etc/os-release && . /etc/os-release)}"

      In conversation Wednesday, 21-Sep-2022 09:39:47 JST permalink
    • Embed this notice
      Tosti ? (tost@mk.toast.cafe)'s status on Wednesday, 21-Sep-2022 09:39:48 JST Tosti ? Tosti ?
      in reply to

      @aliss@outerheaven.club you are checking for "ID" being empty, but setting "dist"

      In conversation Wednesday, 21-Sep-2022 09:39:48 JST permalink
    • Embed this notice
      aliss (aliss@outerheaven.club)'s status on Wednesday, 21-Sep-2022 09:39:49 JST aliss aliss
      in reply to
      • Tosti ?
      @tost wait why the getopts and how's the mismatch
      In conversation Wednesday, 21-Sep-2022 09:39:49 JST permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • 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.