Не попадитесь на накрученные каналы! Узнайте, не накручивает ли канал просмотры или подписчиков Проверить канал на накрутку
Прикрепить Телеграм-аккаунт Прикрепить Телеграм-аккаунт

Телеграм канал «r_bash»

Подписчики
Всего
45
Сегодня
0
Просмотров на пост
Всего
3
ER
Общий
5.56%
Суточный
6.67%
Динамика публикаций
Telemetr - сервис глубокой аналитики
телеграм-каналов
Получите подробную информацию о каждом канале
Отберите самые эффективные каналы для
рекламных размещений, по приросту подписчиков,
ER, количеству просмотров на пост и другим метрикам
Анализируйте рекламные посты
и креативы
Узнайте какие посты лучше сработали,
а какие хуже, даже если их давно удалили
Оценивайте эффективность тематики и контента
Узнайте, какую тематику лучше не рекламировать
на канале, а какая зайдет на ура
Попробовать бесплатно
Показано 7 из 603 постов
Смотреть все посты
Пост от 27.10.2026 14:15
1
0
0
Improve your Bash testing with Bats

I started solopreneuring a year ago, and my projects have a fair amount of Bash. My annoyances with Bats: I couldn't mock things efficiently, the assertion libraries are scattered over three repos with different naming, and table-driven tests are clumsy. I've written these scripts over the years in my career and thought about open-sourcing them, but never did. I'm using these libraries in my own frameworks and it helps me test my bash scripts in a more unified way, so I've chosen to productionize them and finally putting it out there:

bats-mock mocks and spies on commands and Bash functions. You set behavior with glob/regex rules, run your code, then assert on call counts, exact argv, stdin and call order across commands. Spies call through to the real thing. jasonkarns/bats-mock uses stubs on PATH, so it can't mock a function without unsetting it, and has no spies or stdin checks.

https://github.com/stealth-scale/bats-mock

bats-expect replaces bats-support, bats-assert and bats-file with one library. bats-assert's functions keep their names, options and failure format, so switching is a one-line change. Naming is consistent, and it adds assertions for variables, arrays, namerefs, numbers and JSON.

https://github.com/stealth-scale/bats-expect

bats-matrix does table-driven tests: inputs, expected exit status and expected output in one table, and a failure tells you which row broke and the exact command it ran. Bats' own bats_test_function works too, but needs a loop and a separate test body.

https://github.com/stealth-scale/bats-matrix



bats-test is the image I run it all in: every combination of Bash 4.4/5.1/5.2/5.3 and Bats 1.7.0/1.14.0, GNU tools, jq and a patched kcov.

https://github.com/stealth-scale/bats-test

I've been an engineer for a long time and I care about quality, so my libraries have a 100% line coverage gate in CI. That's how I ended up in a kcov rabbit hole: on Bash 5.3 one suite came out at 0%. kcov's Bash support had three bugs: a single quote inside [[ \]\] made it drop every later hit, it counted every line of a multi-line command while Bash reports one, and its helper killed any bash -c child running with set -u. With the fixes, bats-mock went from 659 lines at 88% to 613 at 100%. The patches are in bats-test. I haven't sent them upstream yet, and I know I should.

If you don't mind switching frameworks, bashunit and ShellSpec already have mocks and data-driven tests. These repos are for staying on Bats.

The linked repo is a small release CLI whose test suite uses all four:

git clone --recurse-submodules https://github.com/stealth-scale/bats-example.git && cd bats-example && make test

It uses Podman (make test RUNTIME=docker for Docker) and runs without network. You need Bash 4.4+, and since the mocks are functions, /usr/bin/curl goes straight past them.

Everything is MIT (the image ships kcov, which is GPL-2.0). For me these tools are a big time-saver.

I'd love to hear what's still annoying to test in your Bash so I can further improve what I've used for years.

https://redd.it/1xgnn8p
@r_bash
Пост от 27.10.2026 05:15
1
0
0
Race condition with | tee -a >(col -b >> "$f") and following function/command that also appends to $f

I'm writing to file $f using the snippet above, and the command after it also writes/appends to $f.

I'm using col because it's for fio --eta=always to display on terminal but not fill up the file with carriage returns or whatever commands that clutter the file and are intended control for the terminal for the purpose of live status updates.

Running it as in the title, the next command begins before col is done and their respective outputs mix a bit.

I believe the problem is that tee is being recognized as having finished/closed whereas >(col -b >> "$f") isn't being tracked and is still writing. I don't understand fully though I recognize, "The process... is run asynchronously."

I've found two solutions, but they don't quite feel right. Let me know if you can think of a better one or of which these two that you prefer.

{
fio --eta=always "${job}" | tee -a >(col -b >> "$f")
} &

wait $!

or

fio --eta=always "${job}" | tee /tmp/fio.log.tmp

cat /tmp/fio.log.tmp | col -b >> "$f"
rm /tmp/fio.log.tmp

The second one, I could probably add a mktemp and trap to both secure and delete the temp file.

https://redd.it/1xgf6pi
@r_bash
Пост от 25.10.2026 22:15
1
0
0
First time learning Bash: macOS vs Linux VM?

I'm learning Bash via Codecademy(maybe, idk if I'll pay for the subscription) and LinkedIn Learning. The specific course I'm starting says macOS is okay but using a Linux VM with something like Virtual Box is preferred since Linux is industry standard.


I haven't worked with VMs before but it is also something I want to learn about, but I don't know what the curve is like for setting something like this up or if it's worth doing as a beginner.

What do y'all recommend?

https://redd.it/1xfaz10
@r_bash
Пост от 24.10.2026 14:15
1
0
0
What should i do now

Heyy i am new to Linux(currently using fedora silver blue) and exploring Linux, recently started exploring Bash for interest now i learn little bits of it like(basic commands , file permissions) from web3school , now what should i learn next ? From where(resource)

https://redd.it/1xe5qxi
@r_bash
Пост от 24.10.2026 06:15
1
0
0
automatically write a shortcut to go to a specific directory

I personally have found that on linux systems, the biggest number of aliases are simply "alias <name> = 'cd <path>'", so it makes sense then to automate this. I wasn't interested making a github repository since this is very simple, and i would expect someone like me to perhaps make a slightly different version of this for whatever they do:

#!/bin/bash
#adds an alias to traverse a directory
if "$#" -ne 2 ; then
echo "Number of argments entered is $#, needs"
echo "exactly 2 arguments to run."
echo
echo "usage: add-alias.sh <alias> <directory-path>"
exit
fi

if "$1" = "-h" ; then
echo "usage: add-alias.sh <alias> <directory-path>"
exit
fi

ALIAS="$1"
DIRECTORY="$2"

echo "alias $ALIAS='cd \""$DIRECTORY"\"'" >> ~/.bashaliases

echo "Written to .bashaliases: alias $ALIAS='cd \""$DIRECTORY"\"'"

the thing that was fun about making this was figuring out the exact quoting to make it work, as some directories are inevitably going to have spaces etc.



https://redd.it/1xdxpbe
@r_bash
Пост от 23.10.2026 12:15
1
0
0
cz: a cd/zoxide-style directory jumper with live filesystem search (ratatui + nucleo + rusqlite) — beta, feedback welcome

I've been building cz, a directory navigator for bash/zsh, and just released v0.2.1 (beta).

Like zoxide, it learns frecency from your visits; unlike zoxide, it also scans the current scope in the background, so it can find folders you've never visited. `czi` opens a picker that also lists files and cd's to the picked file's folder.

Some Rust details that might be interesting:

* **ratatui** picker that updates live while a background BFS thread streams results over mpsc
* **nucleo-matcher** for fuzzy scoring, combined with a frecency multiplier (exact/prefix/substring tiers)
* **rusqlite** (bundled) for history, static **musl** build, 3.7 MB
* the scanner skips symlink loops, /proc-like and network/FUSE mounts (read from /proc/self/mounts), so `cz -r` never hangs on an sshfs mount
* an "auto-jump" rule that can decide using history alone before the scan finishes, by bounding the best possible score of not-yet-seen directories

Repo : [https://github.com/piumalnipun9/cz](https://github.com/piumalnipun9/cz)

Code review and feedback very welcome, especially on the ranking/auto-jump logic (src/search/) and the scanner (src/search/filesystem.rs).

https://redd.it/1xd8gll
@r_bash
Пост от 22.10.2026 21:15
1
0
0
just beautiful way = ) tail -F $(lsof|grep log|awk '{print $9}'|grep '\.log$')

have s nice time

https://redd.it/1xcpm70
@r_bash
Смотреть все посты