Re: is there such a thing as "bytecode" for bash scripts? à la java "bytecode"? ...

2025-09-14 Thread Greg Wooledge
On Sun, Sep 14, 2025 at 09:56:15 -0700, Mike Castle wrote: > If you do the same thing in a loop: > > > while true; do > echo "tom" > sleep 1 > done > > It does not seem to reread. That's because of how the bash parser works. Compound commands (w

Re: is there such a thing as "bytecode" for bash scripts? à la java "bytecode"? ...

2025-09-14 Thread Mike Castle
Shell scripts will also return to the source during execution, seeking to the next line in the file and rereading it. You will often see errors in executing shell scripts if you edit them while they are running, because code has shifted around. For example: $ cat t.sh #!/bin/bash echo &quo

Re: is there such a thing as "bytecode" for bash scripts? à la java "bytecode"? ...

2025-09-06 Thread Greg Wooledge
On Sat, Sep 06, 2025 at 19:27:06 +0200, lbrt...@tutamail.com wrote: > > The way I see thingsbash or any other OS script type must have a compilation > and decodingphase before it talks to the OS. How do you get that stream of > datathat the OS digests? No, bash does not use

is there such a thing as "bytecode" for bash scripts? à la java "bytecode"? ...

2025-09-06 Thread lbrtchx
in java you canalways disassemble its bytecode as it is digested by the JVM dealingthen directly with the OS. The way I see thingsbash or any other OS script type must have a compilation and decodingphase before it talks to the OS. How do you get that stream of datathat the OS digests? I do

Re: Please check my sudo bash script

2025-09-03 Thread David Christensen
On 9/3/25 04:00, Tom Browder wrote: On Tue, Sep 2, 2025 at 07:40 Tom Browder wrote: On Tue, Sep 2, 2025 at 12:30 AM David Christensen wrote ... David, I finished following your 'recipe' a few minutes ago, with mods for my system. I just rebooted and see all three new drives where I expecte

Re: Please check my sudo bash script

2025-09-03 Thread Tom Browder
On Tue, Sep 2, 2025 at 07:40 Tom Browder wrote: > On Tue, Sep 2, 2025 at 12:30 AM David Christensen > wrote ... David, I finished following your 'recipe' a few minutes ago, with mods for my system. I just rebooted and see all three new drives where I expected them to be! Thanks again, David.

Re: Please check my sudo bash script)OT:

2025-09-03 Thread Jonathan Dowland
On Sun Aug 31, 2025 at 5:14 PM BST, john doe wrote: Provisioning a server is an other thing. You realy want to look at preseeding, Ansible, Opentoffu and Puppet or alike.alternative. Those are overkill, IMHO, until you are managing a set of servers larger than 2 or 3. -- Please do not CC me

Re: Please check my sudo bash script

2025-09-02 Thread David Christensen
On 9/2/25 05:40, Tom Browder wrote: On Tue, Sep 2, 2025 at 12:30 AM David Christensen wrote: ... David, thanks so much. I do appreciate this message in particular which is the "looking over my shoulder" guidance I was looking for before I proceed to the next step. Blessings! -Tom YW. I am

Re: Please check my sudo bash script

2025-09-02 Thread David Christensen
On 9/1/25 15:36, Tom Browder wrote: On Mon, Sep 1, 2025 at 13:19 Tom Browder wrote: ... That info above is old. Since then I've used gparted. Output from "lsblk": NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:00 3.6T 0 disk `-sda1 8:10 3.6T 0 part sdb 8:16 0

Re: Please check my sudo bash script

2025-09-02 Thread Greg
On 2025-08-31, Tom Browder wrote: > > Does this bash fragment look safe for using bash vars for the first disk: > > SDX=sda > sudo parted /dev/${SDX} mklabel gpt > sudo parted -a opt /dev/${SDX} mkpart primary ext4=0% 100% > sudo mkfs.ext4 /dev/${SDX} The mkfs step must targ

Re: Please check my sudo bash script

2025-09-02 Thread David Christensen
OINT # sda 3.6T # <= new disk sda # sdb465.8G # |-sdb1 512M vfat /boot/efi # |-sdb2 464.3G ext4 / # `-sdb3 976M swap [SWAP] # sdc931.5G # <= new disk sdc # sdd931.5G # <= new disk sdd Does this bash fragment look safe for

Re: Please check my sudo bash script

2025-09-02 Thread Tom Browder
On Tue, Sep 2, 2025 at 8:05 AM Andrew M.A. Cater wrote: ... > Hi Tom, > > Do you have a copy of debian-handbook? If not, apt install it. I completely forgot about that. Thanks so much, Andrew! -Tom

Re: Please check my sudo bash script

2025-09-02 Thread Tom Browder
On Tue, Sep 2, 2025 at 12:30 AM David Christensen wrote: ... David, thanks so much. I do appreciate this message in particular which is the "looking over my shoulder" guidance I was looking for before I proceed to the next step. Blessings! -Tom

Re: Please check my sudo bash script

2025-09-02 Thread Andrew M.A. Cater
On Mon, Sep 01, 2025 at 08:48:03PM -0700, David Christensen wrote: > On 9/1/25 04:47, Tom Browder wrote: > > > > Thanks to all who have answered. > > Hi Tom, You do have a copy of debian-handbook? If not, apt install it. Written by Raphael Hertzog and Roland Mas - my hardback is somewhere else

Re: Please check my sudo bash script

2025-09-01 Thread David Christensen
On 9/1/25 04:47, Tom Browder wrote: On Sun, Aug 31, 2025 at 09:55 Tom Browder wrote: I just added three new SSD and want to prep them for use. Thanks to all who have answered. I used to own a copy of the Unix server guide when I was working (using Sun OS and Irix). For home use I bought (a

Re: Please check my sudo bash script

2025-09-01 Thread Tom Browder
On Mon, Sep 1, 2025 at 13:19 Tom Browder wrote: ... > > That info above is old. Since then I've used gparted. > > Output from "lsblk": > > NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT > sda 8:00 3.6T 0 disk > `-sda1 8:10 3.6T 0 part > sdb 8:16 0 465.8G 0 disk > |-sdb1

Re: Please check my sudo bash script

2025-09-01 Thread Tom Browder
On Mon, Sep 1, 2025 at 11:42 AM Greg wrote: > > On 2025-08-31, Tom Browder wrote: ... > > SDX=sda > > sudo parted /dev/${SDX} mklabel gpt > > sudo parted -a opt /dev/${SDX} mkpart primary ext4=0% 100% > > sudo mkfs.ext4 /dev/${SDX} That info above is old. Since then I've used gparted. Output fr

Re: Please check my sudo bash script)OT:

2025-09-01 Thread songbird
Tom Browder wrote: > On Sun, Aug 31, 2025 at 10:46 alain williams wrote: >> On Sun, Aug 31, 2025 at 05:37:27PM +0200, john doe wrote: >> > On 8/31/25 4:55 PM, Tom Browder wrote: >> > > I just added three new SSD and want to prep them for use. >> > > >> > > I plan to use a script to do that increme

Re: Please check my sudo bash script

2025-09-01 Thread Tom Browder
On Mon, Sep 1, 2025 at 06:56 Tom Browder wrote: > On Mon, Sep 1, 2025 at 06:47 Tom Browder wrote: > I just fired up gparted and all became clear! I haven't used it in several > years and > completely forgot about it. Well, one more question: how to add the new disks so they auto mount? First,

Re: Please check my sudo bash script

2025-09-01 Thread Tom Browder
On Mon, Sep 1, 2025 at 06:47 Tom Browder wrote: I just fired up gparted and all became clear! I haven't used it in several years and completely forgot about it. Thank you my fellow Debianites! -Tom

Re: Please check my sudo bash script

2025-09-01 Thread Tom Browder
On Sun, Aug 31, 2025 at 09:55 Tom Browder wrote: > I just added three new SSD and want to prep them for use. Thanks to all who have answered. I used to own a copy of the Unix server guide when I was working (using Sun OS and Irix). For home use I bought (and still have) the "Ubuntu Server Guid

Re: Please check my sudo bash script

2025-08-31 Thread David
# NAME SIZE FSTYPE MOUNTPOINT > # sda 3.6T # <= new disk sda > # sdb465.8G > # |-sdb1 512M vfat /boot/efi > # |-sdb2 464.3G ext4 / > # `-sdb3 976M swap [SWAP] > # sdc931.5G # <= new disk sdc > # sdd931.5G

Re: Please check my sudo bash script

2025-08-31 Thread Michael Paoli
On Sun, Aug 31, 2025 at 7:56 AM Tom Browder wrote: > Does this bash fragment look safe for using bash vars for the first disk: > SDX=sda > sudo parted /dev/${SDX} mklabel gpt > sudo parted -a opt /dev/${SDX} mkpart primary ext4=0% 100% > sudo mkfs.ext4 /dev/${SDX} Nope. S

Re: Please check my sudo bash script

2025-08-31 Thread Jeffrey Walton
AME SIZE FSTYPE MOUNTPOINT > # sda 3.6T # <= new disk sda > # sdb465.8G > # |-sdb1 512M vfat /boot/efi > # |-sdb2 464.3G ext4 / > # `-sdb3 976M swap [SWAP] > # sdc931.5G # <= new disk sdc > # sdd 931.5G

Re: Please check my sudo bash script)OT:

2025-08-31 Thread john doe
On 8/31/25 6:00 PM, Tom Browder wrote: On Sun, Aug 31, 2025 at 10:46 alain williams wrote: On Sun, Aug 31, 2025 at 05:37:27PM +0200, john doe wrote: On 8/31/25 4:55 PM, Tom Browder wrote: I just added three new SSD and want to prep them for use. I plan to use a script to do that incremental

Re: Please check my sudo bash script

2025-08-31 Thread Tom Browder
On Sun, Aug 31, 2025 at 10:28 Charles Curley < charlescur...@charlescurley.com> wrote: … > Two style notes: … > Thanks, Charles! -Tom

Re: Please check my sudo bash script)OT:

2025-08-31 Thread Tom Browder
On Sun, Aug 31, 2025 at 10:46 alain williams wrote: > On Sun, Aug 31, 2025 at 05:37:27PM +0200, john doe wrote: > > On 8/31/25 4:55 PM, Tom Browder wrote: > > > I just added three new SSD and want to prep them for use. > > > > > > I plan to use a script to do that incrementally. Given the disks s

Re: Please check my sudo bash script)OT:

2025-08-31 Thread alain williams
On Sun, Aug 31, 2025 at 05:37:27PM +0200, john doe wrote: > On 8/31/25 4:55 PM, Tom Browder wrote: > > I just added three new SSD and want to prep them for use. > > > > I plan to use a script to do that incrementally. Given the disks show > > the following when running "lsblk -o ..." ('# ' added)

Re: Please check my sudo bash script)OT:

2025-08-31 Thread john doe
On 8/31/25 4:55 PM, Tom Browder wrote: I just added three new SSD and want to prep them for use. I plan to use a script to do that incrementally. Given the disks show the following when running "lsblk -o ..." ('# ' added): This is not our job to do your work, you also need to do it yourself.

Re: Please check my sudo bash script

2025-08-31 Thread Charles Curley
On Sun, 31 Aug 2025 09:55:04 -0500 Tom Browder wrote: > SDX=sda > sudo parted /dev/${SDX} mklabel gpt > sudo parted -a opt /dev/${SDX} mkpart primary ext4=0% 100% > sudo mkfs.ext4 /dev/${SDX} Two style notes: * I would put quotes around any variable, in this case $(SDX}. * I would use lower ca

Please check my sudo bash script

2025-08-31 Thread Tom Browder
k sda # sdb465.8G # |-sdb1 512M vfat /boot/efi # |-sdb2 464.3G ext4 / # `-sdb3 976M swap [SWAP] # sdc931.5G # <= new disk sdc # sdd931.5G # <= new disk sdd Does this bash fragment look safe for using bash vars for the first disk: S

Re: recognizing an xterm running only bash from the CLI

2025-08-13 Thread Michael Paoli
have a similar function toX() to be used on a virtual > terminal that would print some text on the xterm running only bash How exactly do you define "only running bash"? That that's the only PID with that xterm as controlling tty? That bash is the only child PID of the xterm PID? That

Re: recognizing an xterm running only bash from the CLI

2025-08-12 Thread Mike McClain
On Mon, Aug 11, 2025 at 04:23:36PM +0200, Nicolas George wrote: > So this was a XY problem. If you say so but I don't see it that way. > Do not try to guess which terminal is running ???only bash???, have the I wasn't trying to guess and you gave me the answer, Thank You. >

Re: recognizing an xterm running only bash from the CLI

2025-08-11 Thread Nicolas George
Greg Wooledge (HE12025-08-11): > I still think that having both /dev/tty9 and "this one xterm" both > connected to the same tmux/screen session is going to be the best > long-term solution to *whatever* the actual workflow issue is. That might work depending on the use case, or worse than before.

Re: recognizing an xterm running only bash from the CLI

2025-08-11 Thread Dan Ritter
Greg Wooledge wrote: > On Mon, Aug 11, 2025 at 10:31:38 -0400, Dan Ritter wrote: > > Recipe: > > 1) Install screen. > 2) On /dev/tty9, run "screen -S shared" to create a named session. > 3) In X, open an xterm (ideally with the same dimensions as the VT). > 4) In that xterm, run "screen -x -

Re: recognizing an xterm running only bash from the CLI

2025-08-11 Thread Greg Wooledge
On Mon, Aug 11, 2025 at 10:31:38 -0400, Dan Ritter wrote: > Is your actual question, then: > > How can I use a command line command to write something > semi-ephemeral to something displaying in X? > > Options that come to mind: > - lsof /dev/pts/* > - use a notifications demon (e.g.

Re: recognizing an xterm running only bash from the CLI

2025-08-11 Thread Nicolas George
> ps ax | grep [b]ash | grep -o 'pts...' … will not tell us what terminal is running *only* bash. -- Nicolas George

Re: recognizing an xterm running only bash from the CLI

2025-08-11 Thread John Hasler
Mike McClain writes: > If I can learn how to determine which /dev/pts/? is running only bash > and not mc or something else then I can write toX() to just work. ps ax | grep [b]ash | grep -o 'pts...' -- John Hasler j...@sugarbit.com Elmwood, WI USA

Re: recognizing an xterm running only bash from the CLI

2025-08-11 Thread Dan Ritter
it appear on the other terminal? > > Sorry I wasn't clear, I'll try again. > I've defined to9 () { echo "$1" > /dev/tty9 } to be used from an xterm. > I'd like to have a similar function toX() to be used on a virtual > terminal that would print some

Re: recognizing an xterm running only bash from the CLI

2025-08-11 Thread Nicolas George
Mike McClain (HE12025-08-11): > I've defined to9 () { echo "$1" > /dev/tty9 } to be used from an xterm. > I'd like to have a similar function toX() to be used on a virtual > terminal that would print some text on the xterm running only bash > but that xterm vari

Re: recognizing an xterm running only bash from the CLI

2025-08-11 Thread Mike McClain
wasn't clear, I'll try again. I've defined to9 () { echo "$1" > /dev/tty9 } to be used from an xterm. I'd like to have a similar function toX() to be used on a virtual terminal that would print some text on the xterm running only bash but that xterm varies which /dev

Re: recognizing an xterm running only bash from the CLI

2025-08-10 Thread David Wright
om the CLI to X I have to go to X and see which > /dev/pts/* is just running bash. Is that so that you can have "You have mail in /var/mail/mike" typed in the middle of your command lines? > Does anyone know a way to ID that open xterm from the CLI? Cheers, David.

Re: recognizing an xterm running only bash from the CLI

2025-08-10 Thread Greg Wooledge
om the CLI to X I have to go to X and see which > /dev/pts/* is just running bash. > Does anyone know a way to ID that open xterm from the CLI? I'm having trouble understanding what you're saying here. When you say "copy my entry", does that mean you want to type stu

recognizing an xterm running only bash from the CLI

2025-08-10 Thread Mike McClain
Most of my Linux use is on the commandline. When I launch X I always start an xterm, one running mc and firefox. >From X I have a tiny script 'to9' that copies my entry to /dev/tty9. Going the other way from the CLI to X I have to go to X and see which /dev/pts/* is just running bash

Re: How does bash interpret tilde character?

2025-08-10 Thread debian-user
. in context, what does " ~/ " mean? > > 2. what reference would answer a similar question? > >[ NOTE BENE: The search may be more beneficial than the > > answer ] > > It's your home directory. I would think any bash reference would tell > you s

Re: How does bash interpret tilde character?

2025-08-10 Thread Mike Castle
On Sun, Aug 10, 2025 at 7:23 AM Vincent Lefevre wrote: > BTW, a difference between shells: > With bash: > > $ echo ~ foo=~/bar:~/rod > /home/vinc17 foo=/home/vinc17/bar:/home/vinc17/rod Less about shells and more about compliance. $ echo ~ foo=~/bar:~/rod /home/nexus foo=/home/

Re: How does bash interpret tilde character?

2025-08-10 Thread Patrick Wiseman
ce would answer a similar question? >[ NOTE BENE: The search may be more beneficial than the answer ] > It's your home directory. I would think any bash reference would tell you so, but don't have one in front of me at the moment. Patrick

Re: How does bash interpret tilde character?

2025-08-10 Thread Vincent Lefevre
od With mksh: $ echo ~ foo=~/bar:~/rod /home/vinc17 foo=/home/vinc17/bar:~/rod With bash: $ echo ~ foo=~/bar:~/rod /home/vinc17 foo=/home/vinc17/bar:/home/vinc17/rod With zsh: qaa% echo ~ foo=~/bar:~/rod /home/vinc17 foo=~/bar:~/rod qaa% setopt MAGIC_EQUAL_SUBST qaa% echo ~ foo=~/bar:~/rod

Re: How does bash interpret tilde character?

2025-08-10 Thread Richard Owlett
al context and usage, "~/" can AFAIK be treated as exactly equivalent to "$HOME/". 2. what reference would answer a similar question? There are probably plenty of places online which would explain it, but the canonical place AFAIK is the bash man page. There is a spe

Re: How does bash interpret tilde character?

2025-08-10 Thread The Wanderer
On 2025-08-10 at 08:06, Vincent Lefevre wrote: > On 2025-08-10 08:00:15 -0400, The Wanderer wrote: > >> On 2025-08-10 at 07:51, Richard Owlett wrote: >> >> > About 5 years ago the response I got was: >> > >> >> Use the 'history' command, or 'cat ~/.bash_history'. >> > >> > I have two questions:

Re: How does bash interpret tilde character?

2025-08-10 Thread Vincent Lefevre
On 2025-08-10 08:00:15 -0400, The Wanderer wrote: > On 2025-08-10 at 07:51, Richard Owlett wrote: > > > About 5 years ago the response I got was: > > > >> Use the 'history' command, or 'cat ~/.bash_history'. > > > > I have two questions: > > 1. in context, what does " ~/ " mean? > > In the

Re: How does bash interpret tilde character?

2025-08-10 Thread Vincent Lefevre
ould answer a similar question? > [ NOTE BENE: The search may be more beneficial than the answer ] Look for "tilde expansion" in the bash(1) man page. -- Vincent Lefèvre - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17

Re: How does bash interpret tilde character?

2025-08-10 Thread The Wanderer
ext and usage, "~/" can AFAIK be treated as exactly equivalent to "$HOME/". > 2. what reference would answer a similar question? There are probably plenty of places online which would explain it, but the canonical place AFAIK is the bash man page. There is a specific s

How does bash interpret tilde character?

2025-08-10 Thread Richard Owlett
About 5 years ago the response I got was: Use the 'history' command, or 'cat ~/.bash_history'. I have two questions: 1. in context, what does " ~/ " mean? 2. what reference would answer a similar question? [ NOTE BENE: The search may be more beneficial than the answer ] TIA

Re: Google searches requiring JavaScript (was Re: Can a Bash function be named "w3m" ?)

2025-01-30 Thread Roy J. Tellason, Sr.
On Thursday 30 January 2025 10:13:39 am Richard Owlett wrote: > > On another, I've switched search-engine defaults from > > Google to (the HTML-only version of) DuckDuckGo. So far neither is > > giving me such an obviously superior experience for me to decide to > > switch the other machine over so

Re: Can a Bash function be named "w3m" ?

2025-01-30 Thread David Wright
On Thu 30 Jan 2025 at 05:52:02 (-0800), Will Mengarini wrote: > * Roger Price [25-01/30=Th 13:59 +0100]: > > $wrongCodeForCheckingWhetherAliasExists && unalias w3m > > When I want to unalias something that might already be unaliased (as > when it's in .bashrc), I just code > unalias foo 2>/dev/

Re: Can a Bash function be named "w3m" ?

2025-01-30 Thread Jeffrey Walton
On Thu, Jan 30, 2025 at 11:17 AM Will Mengarini wrote: > [...] > Speaking of w3m, was anybody part of its dev team long enough > ago to know what happened to it? When I tried to join its > mailing list linked from I got > no response, even though I tried twice, a fe

Re: Google searches requiring JavaScript (was Re: Can a Bash function be named "w3m" ?)

2025-01-30 Thread Richard Owlett
On 1/30/25 8:15 AM, The Wanderer wrote: On 2025-01-30 at 08:52, Will Mengarini wrote: w3m needs some serious maintenance. It's still my favorite browser, but I hear Google is planning to start requiring Javascript for searches, so somebody's going to have to step up if w3m is to remain viable.

Re: Can a Bash function be named "w3m" ?

2025-01-30 Thread Roger Price
On Thu, 30 Jan 2025, Loris Bennett wrote: > Roger Price writes: > > [[ $(type -t w3m) == "w3m" ]] && unalias w3m > > Shouldn't that be > > [[ $(type -t w3m) == "alias" ]] && unalias w3m You are right! From the Bash man

Google searches requiring JavaScript (was Re: Can a Bash function be named "w3m" ?)

2025-01-30 Thread The Wanderer
On 2025-01-30 at 08:52, Will Mengarini wrote: > w3m needs some serious maintenance. It's still my favorite browser, > but I hear Google is planning to start requiring Javascript for > searches, so somebody's going to have to step up if w3m is to remain > viable. Planning to? They already have -

Re: Can a Bash function be named "w3m" ?

2025-01-30 Thread Will Mengarini
* Roger Price [25-01/30=Th 13:59 +0100]: > $wrongCodeForCheckingWhetherAliasExists && unalias w3m When I want to unalias something that might already be unaliased (as when it's in .bashrc), I just code unalias foo 2>/dev/null because file descriptor 2 is the standard error output. > w3m() { /

Re: Can a Bash function be named "w3m" ?

2025-01-30 Thread Loris Bennett
Roger Price writes: > On a Debian 12 machine with bash 5.2.15-2+b7, I had this alias in my .bashrc > > alias w3m='/usr/bin/w3m -no-cookie -o auto-image=TRUE ' > > I understand that aliases are frowned on and should be written as functions, > so > I wrote

Re: Can a Bash function be named "w3m" ?

2025-01-30 Thread Roger Price
me w3m before defining the function. > POSIX sh only defines "foo()". > "function foo()" is therefore purely a bash extension. I stick to the basic definition of Bash functions. Roger

Re: Can a Bash function be named "w3m" ?

2025-01-30 Thread tomas
On Thu, Jan 30, 2025 at 08:18:26AM -0500, Greg Wooledge wrote: > On Thu, Jan 30, 2025 at 14:10:33 +0100, to...@tuxteam.de wrote: > > Try prefixing the thing with the builtin `function': > > > > function w3m() ... > > That would still leave the alias in place, though. So, both the alias > and t

Re: Can a Bash function be named "w3m" ?

2025-01-30 Thread Greg Wooledge
elieve, if you actually try to run w3m at that point. You need to unalias w3m first. That's the real answer here. Also, just as a tangent, "function" is a bash extension that came from ksh. In ksh, there are two different ways to define a function: "foo()" and "functi

Re: Can a Bash function be named "w3m" ?

2025-01-30 Thread tomas
> > and received the error message > > > > bash: .bashrc: line 86: syntax error near unexpected token `(' > > bash: .bashrc: line 86: `w3m() { /usr/bin/w3m -no-cookie -o > > auto-image=TRUE $@ ; }' > > The problem is you *already* have the alias, and the

Re: Can a Bash function be named "w3m" ?

2025-01-30 Thread Greg Wooledge
On Thu, Jan 30, 2025 at 13:59:37 +0100, Roger Price wrote: > alias w3m='/usr/bin/w3m -no-cookie -o auto-image=TRUE ' > w3m() { /usr/bin/w3m -no-cookie -o auto-image=TRUE $@ ; } > > and received the error message > > bash: .bashrc: line 86: syntax error near

Re: Can a Bash function be named "w3m" ?

2025-01-30 Thread tomas
On Thu, Jan 30, 2025 at 01:59:37PM +0100, Roger Price wrote: > On a Debian 12 machine with bash 5.2.15-2+b7, I had this alias in my .bashrc > > alias w3m='/usr/bin/w3m -no-cookie -o auto-image=TRUE ' > > I understand that aliases are frowned on and should be written

Can a Bash function be named "w3m" ?

2025-01-30 Thread Roger Price
On a Debian 12 machine with bash 5.2.15-2+b7, I had this alias in my .bashrc alias w3m='/usr/bin/w3m -no-cookie -o auto-image=TRUE ' I understand that aliases are frowned on and should be written as functions, so I wrote [[ $(type -t w3m) == "w3m" ]] && unalias w

Re: Bash expression to detect dying RAID devices

2024-12-24 Thread Charles Curley
On Tue, 24 Dec 2024 15:45:31 +0100 (CET) Roger Price wrote: > File /proc/mdstat indicates a dying RAID device with an output > section such as > > md3 : active raid1 sdg6[0] > 871885632 blocks super 1.0 [2/1] [U_] > bitmap: 4/7 pages [16KB], 65536KB chunk > > Note the [U-]. Th

Re: Bash expression to detect dying RAID devices

2024-12-24 Thread Roger Price
On Tue, 24 Dec 2024, Greg Wooledge wrote: On Tue, Dec 24, 2024 at 15:45:31 +0100, Roger Price wrote: md3 : active raid1 sdg6[0] 871885632 blocks super 1.0 [2/1] [U_] bitmap: 4/7 pages [16KB], 65536KB chunk Note the [U-]. There isn't any [U-] in that output. There is [U_].

Re: Bash expression to detect dying RAID devices

2024-12-24 Thread Andy Smith
Hi, On Tue, Dec 24, 2024 at 03:45:31PM +0100, Roger Price wrote: > I would like to scan /proc/mdstat and set a flag if [U-], [-U] or [--] > occur. Others have pointed out your '-' vs '_' confusion. But are you sure you wouldn't rather just rely on the "mdadm --monitor" command that emails you whe

Re: Bash expression to detect dying RAID devices

2024-12-24 Thread Nicolas George
Roberto C. Sánchez (12024-12-24): > I think that '==' is the wrong tool. string1 == string2 string1 = string2 True if the strings are equal. = should be used with the test command for POSIX conformance. When used with the [[ command,

Re: Bash expression to detect dying RAID devices

2024-12-24 Thread Greg Wooledge
On Tue, Dec 24, 2024 at 10:37:29 -0500, Roberto C. Sánchez wrote: > I think that '==' is the wrong tool. That is testing for string > equality, whilst you are looking for a partial match. This is what I was > able to get working after hacking on it for a minute or two: > &

Re: Bash expression to detect dying RAID devices

2024-12-24 Thread Roberto C . Sánchez
performs are trying to match '-' (which isn't part of the output). > My current attempt is > > #! /bin/bash -u > set -x > BAD=0; > while read L; > do if [[ $L == *"[U-]"* ]]; then B=1; fi; > if [[ $L == *"[-U]"* ]]; then B=1; f

Re: Bash expression to detect dying RAID devices

2024-12-24 Thread Stefan Monnier
> File /proc/mdstat indicates a dying RAID device with an output section such > as > > md3 : active raid1 sdg6[0] >871885632 blocks super 1.0 [2/1] [U_] >bitmap: 4/7 pages [16KB], 65536KB chunk > > Note the [U-]. I can't see a "[U-]", only a "[U_]" Stefan

Re: Bash expression to detect dying RAID devices

2024-12-24 Thread Greg Wooledge
On Tue, Dec 24, 2024 at 15:45:31 +0100, Roger Price wrote: > File /proc/mdstat indicates a dying RAID device with an output section such > as > > md3 : active raid1 sdg6[0] >871885632 blocks super 1.0 [2/1] [U_] >bitmap: 4/7 pages [16KB], 65536KB chunk > > Note the [U-]. There i

Re: Bash expression to detect dying RAID devices

2024-12-24 Thread Nicolas George
Roger Price (12024-12-24): > File /proc/mdstat indicates a dying RAID device with an output section such > as Maybe try to find a more script-friendly source for that information in /sys/class/block/md127/md/? Regards, -- Nicolas George

Bash expression to detect dying RAID devices

2024-12-24 Thread Roger Price
set a flag if [U-], [-U] or [--] occur. My current attempt is #! /bin/bash -u set -x BAD=0; while read L; do if [[ $L == *"[U-]"* ]]; then B=1; fi; if [[ $L == *"[-U]"* ]]; then B=1; fi; if [[ $L == *"[--]"* ]]; then B=1; fi; done < /proc/mdstat

Re: Cleanup in a bash script

2024-10-03 Thread tomas
On Thu, Oct 03, 2024 at 03:19:09PM +0300, Anssi Saari wrote: > writes: > > > What actually happens seems completely different to me: the shell > > gets the EPIPE from the dying tee before it can see the EINTR, right? > > That depends. tee -i will ignore SIGINT but ./script gets it. So it can > k

Re: Cleanup in a bash script

2024-10-03 Thread Anssi Saari
writes: > What actually happens seems completely different to me: the shell > gets the EPIPE from the dying tee before it can see the EINTR, right? That depends. tee -i will ignore SIGINT but ./script gets it. So it can keep writing in the pipe, from the script proper or its SIGINT handler and e

Re: Cleanup in a bash script

2024-10-02 Thread Nicolas George
Greg Wooledge (12024-10-02): > In that case, there are THREE foreground processes which receive a SIGINT: > > * The interactive shell, which ignores it, because interactive shells >always ignore SIGINT. You are very right on the rest, but this is a mistake: the interactive shell is not in th

Re: Cleanup in a bash script

2024-10-02 Thread tomas
On Wed, Oct 02, 2024 at 08:17:34AM -0400, Greg Wooledge wrote: [...] Thanks for your (as always) very exhaustive description. > What I'm mostly trying to convey here, though, is that signals do not > *propagate* from one process to another in any kind of automatic way. That's more or less what

Re: Cleanup in a bash script

2024-10-02 Thread Greg Wooledge
ich ignores it, because interactive shells always ignore SIGINT. * The ./script process, which is presumably expanded to "/bin/bash ./script". * The tee -i log process. We know the interactive shell ignores it, and we can reasonably assume that the tee will accept it and terminate.

Re: Cleanup in a bash script

2024-10-02 Thread tomas
On Wed, Oct 02, 2024 at 02:43:11PM +0300, Anssi Saari wrote: > writes: [...] > > Explain to us what you really mean by "signals pass up the pipe", then > > things > > might become clearer. > > I realize I didn't spell it out. It's the, to me, obvious solution to > Tim's problem, as he wrote: >

Re: Cleanup in a bash script

2024-10-02 Thread Anssi Saari
yone else mention >> >> it. tee has had the -i option to ignore interrupt signals for ages. The >> >> non-obvious side effect is INT signals pass up the pipe, in your case to >> >> bash running your script. >> > >> > Signals don't "pass

Re: Cleanup in a bash script

2024-10-01 Thread tomas
ke this: > >> > > >> > ./script |& tee log > >> > > >> > and now it doesn't clean up if I it. > >> > >> Just a point here about tee since I didn't see anyone else mention > >> it. tee has had the -i optio

Re: Cleanup in a bash script

2024-10-01 Thread Anssi Saari
; and now it doesn't clean up if I it. >> >> Just a point here about tee since I didn't see anyone else mention >> it. tee has had the -i option to ignore interrupt signals for ages. The >> non-obvious side effect is INT signals pass up the pipe, in your case to >

Re: Cleanup in a bash script

2024-09-30 Thread Tim Woodall
ing? In this particular case it's almost certain that the tee program will have gone away before the bash script calls the exit handler. That last sentence seems _very_ relevant here. If the other end of the pipe is gone, then the shell builtin `echo` probably fails with SIGPIPE/EPIPE. So will

Re: Cleanup in a bash script

2024-09-30 Thread Greg Wooledge
st a point here about tee since I didn't see anyone else mention > it. tee has had the -i option to ignore interrupt signals for ages. The > non-obvious side effect is INT signals pass up the pipe, in your case to > bash running your script. Signals don't "pass up the pipe&

Re: Cleanup in a bash script

2024-09-30 Thread Anssi Saari
re interrupt signals for ages. The non-obvious side effect is INT signals pass up the pipe, in your case to bash running your script.

Re: Cleanup in a bash script

2024-09-28 Thread Michael Kjörling
g? > > In this particular case it's almost certain that the tee program will > have gone away before the bash script calls the exit handler. That last sentence seems _very_ relevant here. If the other end of the pipe is gone, then the shell builtin `echo` probably fails with SIGPIPE

Re: Cleanup in a bash script

2024-09-28 Thread Tim Woodall
On Sat, 28 Sep 2024, Greg Wooledge wrote: On Sat, Sep 28, 2024 at 14:53:10 +0100, Tim Woodall wrote: Is there a way in bash to guarantee that a trap gets called for cleanup in a script? #!/bin/bash trap cleanup EXIT cleanup() { ... } This works in bash -- i.e., it calls the cleanup

Re: Cleanup in a bash script

2024-09-28 Thread Greg Wooledge
On Sat, Sep 28, 2024 at 15:17:47 +0100, Alain D D Williams wrote: > On Sat, Sep 28, 2024 at 10:13:59AM -0400, Greg Wooledge wrote: > > On Sat, Sep 28, 2024 at 14:53:10 +0100, Tim Woodall wrote: > > > Is there a way in bash to guarantee that a trap gets called for cleanup

Re: Cleanup in a bash script

2024-09-28 Thread Alain D D Williams
On Sat, Sep 28, 2024 at 10:13:59AM -0400, Greg Wooledge wrote: > On Sat, Sep 28, 2024 at 14:53:10 +0100, Tim Woodall wrote: > > Is there a way in bash to guarantee that a trap gets called for cleanup > > in a script? > > #!/bin/bash > trap cleanup EXIT > cleanup() { &g

Re: Cleanup in a bash script

2024-09-28 Thread Greg Wooledge
On Sat, Sep 28, 2024 at 14:53:10 +0100, Tim Woodall wrote: > Is there a way in bash to guarantee that a trap gets called for cleanup > in a script? #!/bin/bash trap cleanup EXIT cleanup() { ... } This works in bash -- i.e., it calls the cleanup function regardless of whether the shell

Re: Cleanup in a bash script

2024-09-28 Thread john doe
On 9/28/24 15:53, Tim Woodall wrote: Is there a way in bash to guarantee that a trap gets called for cleanup in a script? I have a script that works perfectly normally and cleans up after itself, even if it goes wrong. However on trying to debug something else, I wanted to run it like this

Cleanup in a bash script

2024-09-28 Thread Tim Woodall
Is there a way in bash to guarantee that a trap gets called for cleanup in a script? I have a script that works perfectly normally and cleans up after itself, even if it goes wrong. However on trying to debug something else, I wanted to run it like this: ./script |& tee log and now it doe

Re: BASH reference for those who are "learning by doing"?

2024-09-10 Thread Lee
On Tue, Sep 10, 2024 at 5:05 AM Anssi Saari wrote: > > Karl Vogel writes: > > > Have you tried some different fonts? My eyesight is poor, and a good > > font made all the difference. > > > > https://bezoar.org/posts/2023/0214/font-screenshots/ > > Fonts on what? I mostly can't control fonts on doc

Re: BASH reference for those who are "learning by doing"?

2024-09-10 Thread George at Clug
On Tuesday, 10-09-2024 at 18:59 Anssi Saari wrote: > George at Clug writes: > > > Have you tried 100 Hz or greater monitors? All my monitors are 60Hz. I > > wonder if these help with prolonged computer use? > > In my home setup one monitor does 75 Hz and the other 144 but I can't > see much

  1   2   3   4   5   6   7   8   9   10   >