From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 15467 invoked from network); 2 Jul 2023 17:22:06 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 2 Jul 2023 17:22:06 -0000 Received: from mail-wm1-f42.google.com ([209.85.128.42]) by 9front; Sun Jul 2 13:20:31 -0400 2023 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-3fbc244d3a8so36066995e9.2 for <9front@9front.org>; Sun, 02 Jul 2023 10:20:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688318429; x=1690910429; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=wUGONBK0Df8xgM8Vb2RlhWh2uv9vo096hgEVJu3iXnw=; b=rgIWjOl5YMa0GqycVZAV/VXSw4qoCEX/S1a8gjgvoBi+PTcb4Qx3GpUhN/ebh7pebf 6naWGlDE0SDgbkssGEKLR5bnE44AU8PngtHHXwxnSlR0JPnPxiSUdmlz+uHZYjfamK7Q R1vKsprghCrZ6gfDIKJhe8prihsE/RGkz/dJsGWsqVNjLQ0GubAKPRzsxkWG9nqJVwQC aS6BcYqnmnYfT+x5IvO8Xzth8YUZrokOzUqL6xBpGMCVmhzIhObP1SMXsd8lmQ1MkA8y KuIAPo/jg3LTcb/ZiiU06M6m3AeKhiIM8LT+EmYGRlGq9Mj8biay+Zl4opzMdMdOj2f/ JYgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688318429; x=1690910429; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wUGONBK0Df8xgM8Vb2RlhWh2uv9vo096hgEVJu3iXnw=; b=BNVUbvzRwGpiPFKCqJEHtsNXmAijLrNJ4Dsrrw0ZFKxSBl8PKRVr1/WPKHstjxpVOM kG36Uh/UBleBEC1OnrRtbXSyRU+ciU5+1PniPWdMAJjLQzMoZo/YhSJLYHWAKE8muXIw izYalsXBo7i+eQwkyFYZxOxQK7tYT/i3RXgkhycWSJY30TGBAmIpJga1sPd833KghEXQ 3lsfWYHNfjPaYHuIdg1UhL3aPWjxT9Dd5CsCVbNJO5z22GOD2i1FPFK9K3ZodwGiGCUt xZC6Dq8KnRUUieX7uthH6jNCXukkMBAsynEBqvtjGP1nI0kTfmg1iNHtQHGA/Wu8xdfs ni3g== X-Gm-Message-State: AC+VfDxTag4LUdSU/ejAXwSDhx9QR5Xs0Eh1SCIz8xD7inkPvwUJ8abo iBnuOUDs1migDLJwUR68Og/+wuNLkgEcaZw+ZWngiITrTHw= X-Google-Smtp-Source: APBJJlFbGeMKxt0Y7bghcrY3TqnfingdMyQMQD/wgHpkOwMSd8UsudAjMEtCSTbvcSvajGbzFBnvaWBDfowTk6fqrCo= X-Received: by 2002:adf:df82:0:b0:314:2e95:1ec9 with SMTP id z2-20020adfdf82000000b003142e951ec9mr3072757wrl.10.1688314892937; Sun, 02 Jul 2023 09:21:32 -0700 (PDT) MIME-Version: 1.0 References: <10b09e19-27ed-495d-82b5-9c79240b8ccb@sirjofri.de> In-Reply-To: <10b09e19-27ed-495d-82b5-9c79240b8ccb@sirjofri.de> From: Amavect Date: Sun, 2 Jul 2023 11:17:46 -0500 Message-ID: To: 9front@9front.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: structured framework ACPI over XML session polling generator Subject: Re: [9front] [PATCH] Kill, kill, slay: banish sed, long live awk! Reply-To: 9front@9front.org Precedence: bulk On Sun, Jul 2, 2023 at 2:46=E2=80=AFAM sirjofri wrote: > > Hello, > > out of curiosity, why s/sed/awk? What's wrong about sed? > > sirjofri The command line arguments are passed to sed through a sed expression, so the program name is parsed as a sed expression and not as a string. This affects program names with a dot (6.out). In practice, this almost never results in name conflicts, so the real reason is that I find the sed version hard to read. For fun, I rewrote the sed version, which makes the command generation obvi= ous: ps | sed -n '/^'$user' .* '$i'$/s%[^ ]* *([0-9]+) .* (.*)$%@{echo kill>/proc/\1/note} # \2%p' Compare to the original: ps | sed -n '/^'$user' .* '$i'$/s%[^ ]* *%~>/proc/%s% *.* (.*)%/note} # \1%s%~%@{echo kill%p' Compare to awk: ps | awk -v 'user=3D'$user -v 'prog=3D'$i '$1 =3D=3D user && $7 =3D=3D prog= {print "@{echo kill>/proc/" $2 "/note} # " $7}' Thanks, Amavect