s/bash
The venerable Bourne-Again Shell.
Posts
How to deal with this issue? โ So I'm writing a Spartan server in bash, and it has a config file for different hostnames. At first, the file would just have lines with a hostname followed by a directory separated by a space, like this: example.com /var/spartan/example example.net /var/spartan/examplenet However, then I decided I should add some way of specifying redirects, since that is a part of the protocol. So I rewrote it so that it would have sections and subsections. sections would be...
๐ฌ 2 comments ยท Mar 03 ยท 4 months ago
Strange errors โ So I was testing my script and I got these errors [preformatted] What is most confusing to me about these errors, is that the lines 177 through 179 don't try to declare anything as the errors would suggest, the first one is even empty! The lines are: [preformatted] What could be the cause of these errors?
๐ฌ 3 comments ยท Mar 02 ยท 4 months ago
How to check if an associative array with a certain name has been declared?
๐ฌ 1 comment ยท Mar 01 ยท 4 months ago
Piping prevents commands from fully executing? โ Why is it, that when I pipe a command into another command, the other command doesn't fully execute? Like if I run echo -e -n "localhost / 0\r\n" | nc localhost 301 or echo -e -n "localhost / 0\r\n" | nc -w 100s localhost 301 it does not output the response from localhost, or even wait for 100 seconds and timeout, it just exits. Why is this?
๐ฌ 6 comments ยท Mar 01 ยท 4 months ago
Name associative array after variable? โ I need to be able to do something like "Declare -A $var", $var["${key}"]="${value}", and echo "$var[${key}]". What would the correct syntax for this be?
๐ฌ 2 comments ยท 1 like ยท Feb 21 ยท 5 months ago
"For line" is interpreted as "for word"? โ Does anyone know how to use a for loop to loop through every line in a file? I've tried googling but the answers i find online seem to be incorrect. Supposedly you can loop through each line in a file by doing: [preformatted] But when I do that it loops through every word instead and says "line n is word". Anyone know why this does not work, and why people online say it does?
๐ฌ 1 comment ยท Feb 20 ยท 5 months ago
Map hostnames to strings in config? โ Earlier today I wrote a post about a Nex server I wrote in bash (it doesn't have networking, but it will take input and respond to it the same way a Nex server would respond if it had gotten that input via TCP, which means if you make it accessible over a network by running something like "nc -lk 1900 -e ./script" it'll work as a regular Nex server), and I thought maybe I could try modifying the code to support the Spartan protocol. The Spartan protocol...
๐ฌ 1 comment ยท 1 like ยท Feb 16 ยท 5 months ago
How I made a kanban bord using coreutils only โ I couldn't find a good kanban tui app, so I decided to try to use a directory as a kanban board, here's how it works: I have a directory that I use as a kanban bord. In this directory, I can create as many subdirectories as I want. Those are the columns of the bord, such as "TODO" or "DONE" to add a task, I just need to $touch column/newtask. It's just an empty file, the task is in its name. To move the task to another column, I can simply use $mv...
๐ฌ 1 comment ยท 4 likes ยท Feb 16 ยท 5 months ago
I made a bash script to play random music from Music directory โ [preformatted]
๐ฌ 4 comments ยท 2024-09-23 ยท 9 months ago
A mistake most bash beginners make โ It's the array variable expantion. here is an example: x=( a b "c d" ); echo ${x[@]} in this example a beginner would thinkg that ${x[@]} would be expanded to 3 fields but no. It would be expanded into 4 field a,b,c,d . It's very confusing. however to prevent it we just quote the parameter expansion like "${x[@]}" and now it would only expand to 3 fields :) hope you learned something new.
๐ฌ 1 comment ยท 3 likes ยท 2024-08-21 ยท 11 months ago
Beginner tips for beautiful diffs? โ I largely prefer command line tools, but when it comes to handling merge conflicts I find command line diff tools confusing (e.g. I'm in vimdiff and I've got these panes open - which is which?) and always end up either using a GUI git client like sublime merge to visualize the diff or dive into the file with conflicts and resolve them manually. Also, there are times when I wish to compare two files or strings. Sometimes I just make some dummy git activity to...
๐ฌ 5 comments ยท 1 like ยท 2024-04-23 ยท 1 year ago
About grep --exclude โ Colud this grep option be problematic? [preformatted] I'd seen more expressions like: [preformatted] But they doesn't cover the "file.txt_bkp" posibility.
๐ฌ 1 comment ยท 2024-02-11 ยท 1 year ago ยท #grep
โ gemini.locrian.zone/tech/xivships.gmi
[SOLVED] Was: Can I get an extra pair of eyes on some code I wrote? โ Edited: ~ew pointed out that there was a naming conflict in the temporary files generated by the geminispace script and the webspace script; they both outputted to a file called 'shuffle', and the webspace script ran before the geminispace script so on occasion there would be some mangling of the latter. This also explains why both...
๐ฌ 1 like ยท 2023-09-28 ยท 2 years ago
Options
Source