For overthewire bandit level 14 nc is used to send password to localhost, if its correct it sends back “Correct!” with the next levels password. I am trying to replicate this but cant.
Solution is here: https://mayadevbe.me/posts/overthewire/bandit/level15/
This is how I tried to replicate it… I opened 2 terminals. In one terminal I started listening for inputs on port 1234. If the input matches “password” I wanted to send back “Success” but I cannot figure out how to send the response back and display it on the client terminal
Server
nc -l -p 1234 | grep "password" | xargs -I {} echo "Success”
Client
nc localhost 1234
> password
this is able to recognize when password is sent but the message is printed out server side. How can I get it to print out on the client side???
Thank you.
https://redd.it/13b961r
@r_bash
Solution is here: https://mayadevbe.me/posts/overthewire/bandit/level15/
This is how I tried to replicate it… I opened 2 terminals. In one terminal I started listening for inputs on port 1234. If the input matches “password” I wanted to send back “Success” but I cannot figure out how to send the response back and display it on the client terminal
Server
nc -l -p 1234 | grep "password" | xargs -I {} echo "Success”
Client
nc localhost 1234
> password
this is able to recognize when password is sent but the message is printed out server side. How can I get it to print out on the client side???
Thank you.
https://redd.it/13b961r
@r_bash
MayADevBe Blog
OverTheWire Bandit Level 14 -> 15 - Walkthrough
A walkthrough of Level 14 -> 15 of the Bandit wargame from OverTheWire. - Netcat and first network communication.
Remove Text Outside margins?
So basically I have a decent collection of PDF/ePub files that I’d like to strip out the header and footer info, like page number, chapter etc etc. so I can pass it through a text to speech generator, is there a reasonable way to accomplish this in a bash noscript? Maybe parameters so I can define the area to keep ?
https://redd.it/13bacau
@r_bash
So basically I have a decent collection of PDF/ePub files that I’d like to strip out the header and footer info, like page number, chapter etc etc. so I can pass it through a text to speech generator, is there a reasonable way to accomplish this in a bash noscript? Maybe parameters so I can define the area to keep ?
https://redd.it/13bacau
@r_bash
Reddit
r/bash on Reddit: Remove Text Outside margins?
Posted by u/GlassBottleCokes - No votes and 2 comments
Need help use AWK if then in a noscript
Good evening (EDT)
I am trying to write a short noscript that returns the last word of a file. This is pretty easy:
#!/bin/bash
sudo apt update &>/home/user/.config/polybar/modules/apt &&
cat /home/user/.config/polybar/modules/apt | awk 'END{print $1}'
(The word at the end of the file is how many APT packages need updating)
However, when everything is up to date, the noscript returns "All" as that is the first word of the last line of the temp file created in line 2 of the noscript.
What is a good way to return the first word of the last line UNLESS that word is "All" in which case "0" (or some other phrase) is returned?
Thank you!
https://redd.it/13b8cj0
@r_bash
Good evening (EDT)
I am trying to write a short noscript that returns the last word of a file. This is pretty easy:
#!/bin/bash
sudo apt update &>/home/user/.config/polybar/modules/apt &&
cat /home/user/.config/polybar/modules/apt | awk 'END{print $1}'
(The word at the end of the file is how many APT packages need updating)
However, when everything is up to date, the noscript returns "All" as that is the first word of the last line of the temp file created in line 2 of the noscript.
What is a good way to return the first word of the last line UNLESS that word is "All" in which case "0" (or some other phrase) is returned?
Thank you!
https://redd.it/13b8cj0
@r_bash
Reddit
r/bash on Reddit: Need help use AWK if then in a noscript
Posted by u/HerefortheLAN - 1 vote and 2 comments
What happens if I do kill -TERM 0
I know sending TERM to 0 will send TERM to ALL the process in current process group but will the following cause infinite loop?
trap "kill -TERM 0" TERM
./ child_process
I am trying to figure out the behaviour of current process after sending kill -TERM 0
https://redd.it/13bphhw
@r_bash
I know sending TERM to 0 will send TERM to ALL the process in current process group but will the following cause infinite loop?
trap "kill -TERM 0" TERM
./ child_process
I am trying to figure out the behaviour of current process after sending kill -TERM 0
https://redd.it/13bphhw
@r_bash
Is it true that bash/sh (or shell languages in general) were first designed to be used by end users and not programmers?
I don't know where I heard or read this first but I can't find any good source on it, is it true that shell languages were first designed to be used by Unix end users in the 70s-90s who didn't know much about programming?
https://redd.it/13bxtlp
@r_bash
I don't know where I heard or read this first but I can't find any good source on it, is it true that shell languages were first designed to be used by Unix end users in the 70s-90s who didn't know much about programming?
https://redd.it/13bxtlp
@r_bash
Reddit
r/bash on Reddit: Is it true that bash/sh (or shell languages in general) were first designed to be used by end users and not programmers?
Posted by u/ED9898A - No votes and 1 comment
How to close all previously running gnome terminals, and start up new ones? pkill doestn work.
Hi, i would really appreciate some help with a simple noscript. I have an autonomous robot running on ROS (robot operating system).
My task right now is this:
1. I have 6-7 terminals running at all times. At a certain point of an automated process (robot coming to dock), I want to close all running terminals
2. Run specific commands to launch robot processes
I have tried using pkill to close all terminals but when I try to run commands after that, it doesnt work. Could you point me in the right direction?
​
Thanks
https://redd.it/13bwqwb
@r_bash
Hi, i would really appreciate some help with a simple noscript. I have an autonomous robot running on ROS (robot operating system).
My task right now is this:
1. I have 6-7 terminals running at all times. At a certain point of an automated process (robot coming to dock), I want to close all running terminals
2. Run specific commands to launch robot processes
I have tried using pkill to close all terminals but when I try to run commands after that, it doesnt work. Could you point me in the right direction?
​
Thanks
https://redd.it/13bwqwb
@r_bash
Reddit
r/bash on Reddit: How to close all previously running gnome terminals, and start up new ones? pkill doestn work.
Posted by u/shady_downforce - No votes and no comments
Help with referencing a variable and dealing with quotes, escapes, and braces?
These are the source folders in an rsync command. It works as-is but I can't figure out how to put this in a variable and then refer to the variable instead. All on one line, it's:
>/Users/$USER/Library/./Mobile\\ Documents/com\~apple\~{Pages,Numbers,Keynote}/ /Users/$USER/./Documents/Folder\\ name
I tried putting it in a variable as
>SOURCE= "/Users/$USER/Library/./Mobile Documents/com\~apple\~{Pages,Numbers,Keynote}/ /Users/$USER/./Documents/Developer/Folder name"
And then referring to
>"${SOURCE}"
I also tried the variable reference without curly braces and without quotes, and adding an escape before the spaces in the variable. Nothing I've tried works. I get an error message that the folder can't be found. The error quotes both folder references together. I think my issue is properly handling spaces when inside a quote that defines a variable, and maybe the braces when in a variable.
My underlying goal is to have a variable that includes all the source folders, and then just refer to the variable in the rsync command.
https://redd.it/13c2br3
@r_bash
These are the source folders in an rsync command. It works as-is but I can't figure out how to put this in a variable and then refer to the variable instead. All on one line, it's:
>/Users/$USER/Library/./Mobile\\ Documents/com\~apple\~{Pages,Numbers,Keynote}/ /Users/$USER/./Documents/Folder\\ name
I tried putting it in a variable as
>SOURCE= "/Users/$USER/Library/./Mobile Documents/com\~apple\~{Pages,Numbers,Keynote}/ /Users/$USER/./Documents/Developer/Folder name"
And then referring to
>"${SOURCE}"
I also tried the variable reference without curly braces and without quotes, and adding an escape before the spaces in the variable. Nothing I've tried works. I get an error message that the folder can't be found. The error quotes both folder references together. I think my issue is properly handling spaces when inside a quote that defines a variable, and maybe the braces when in a variable.
My underlying goal is to have a variable that includes all the source folders, and then just refer to the variable in the rsync command.
https://redd.it/13c2br3
@r_bash
Reddit
r/bash on Reddit: Help with referencing a variable and dealing with quotes, escapes, and braces?
Posted by u/limpingrobot - No votes and 3 comments
Amazing ssh banner for full node
https://github.com/st3b1t/Satoshi.motd
https://preview.redd.it/dzy6w8l3epya1.png?width=763&format=png&auto=webp&v=enabled&s=cd0cd3dc25fe4b15d9727c897255fd8ab426bc70
https://redd.it/13cagbp
@r_bash
https://github.com/st3b1t/Satoshi.motd
https://preview.redd.it/dzy6w8l3epya1.png?width=763&format=png&auto=webp&v=enabled&s=cd0cd3dc25fe4b15d9727c897255fd8ab426bc70
https://redd.it/13cagbp
@r_bash
GitHub
GitHub - st3b1t/SatoshiBanner: Satoshi tribute for your Linux Bitcoin Full Node SSH server motd(message of the day) or banner file
Satoshi tribute for your Linux Bitcoin Full Node SSH server motd(message of the day) or banner file - GitHub - st3b1t/SatoshiBanner: Satoshi tribute for your Linux Bitcoin Full Node SSH server motd...
Fish-like dirhistory (prevd/nextd) for Bash
Hello Bash users,
I while ago I came across this video extolling the virtue of Fish's
Those binding provide a
Zsh via Oh My Zsh provides the Dirhistory plugin to mimic that functionality.
But what about Bash?
I could not find a solution, maybe someone has implemented it, but I could not find it, so I implemented my own solution which is this:
cd() {
local target="$@"
if [ -z "$target" ]; then
# Handle 'cd' without arguments; change to the $HOME directory.
target="$HOME"
fi
# Note, if the target directory is the same as the current directory
# do nothing since we don't want to needlessly populate the directory stack
# with repeat entries.
if [ "$target" != "$PWD" ]; then
\builtin pushd "$target" 1>/dev/null
fi
}
# Alt-Left: rotate back in the directory stack.
bind -x '"\C-x\C-p": "pushd +1 &>/dev/null"'
bind '"\e1;3D":"\C-x\C-p\n"'
# Alt-Right rotate forward in the directory stack.
bind -x '"\C-x\C-n": "pushd -0 &>/dev/null"'
bind '"\e[1;3C":"\C-x\C-n\n"'
We override `cd` to pushd and we then use `pushd` to rotate the directory rather than use `popd` which will eliminate item from the stack. We don't want to eliminate items since we may wish to go forward again, we want rotation.
The binding looks a bit ugly I agree, according to [this StackExchange thread it is the way to silently execute a binding; aka do not print out
But overall, not a lot of code to obtain Fish-like directory stack navigation.
If there are any issues let me know, otherwise enjoy.
https://redd.it/13cfbbp
@r_bash
Hello Bash users,
I while ago I came across this video extolling the virtue of Fish's
Alt-Left and Alt-Right key-bindings.Those binding provide a
cd - experience on steroids, instead of being limited to just one level (back and forward between the current and last directory), Alt-Left (prevd) and Alt-Right (nextd) instead navigate the full directory stack of the current session.Zsh via Oh My Zsh provides the Dirhistory plugin to mimic that functionality.
But what about Bash?
I could not find a solution, maybe someone has implemented it, but I could not find it, so I implemented my own solution which is this:
cd() {
local target="$@"
if [ -z "$target" ]; then
# Handle 'cd' without arguments; change to the $HOME directory.
target="$HOME"
fi
# Note, if the target directory is the same as the current directory
# do nothing since we don't want to needlessly populate the directory stack
# with repeat entries.
if [ "$target" != "$PWD" ]; then
\builtin pushd "$target" 1>/dev/null
fi
}
# Alt-Left: rotate back in the directory stack.
bind -x '"\C-x\C-p": "pushd +1 &>/dev/null"'
bind '"\e1;3D":"\C-x\C-p\n"'
# Alt-Right rotate forward in the directory stack.
bind -x '"\C-x\C-n": "pushd -0 &>/dev/null"'
bind '"\e[1;3C":"\C-x\C-n\n"'
We override `cd` to pushd and we then use `pushd` to rotate the directory rather than use `popd` which will eliminate item from the stack. We don't want to eliminate items since we may wish to go forward again, we want rotation.
The binding looks a bit ugly I agree, according to [this StackExchange thread it is the way to silently execute a binding; aka do not print out
pushd +1 &>/dev/null in the command line. I use Control-p and Control-n intermediaries since I don't use those bindings in the command line. If there is a nicer way to do this, please pass it on.But overall, not a lot of code to obtain Fish-like directory stack navigation.
If there are any issues let me know, otherwise enjoy.
https://redd.it/13cfbbp
@r_bash
YouTube
Fish Shell Tips and Tricks (Can Your Shell Do This?)
Fish is a smart and user-friendly command line shell for Linux and other Unix-like operating systems. Fish has a lot of modern features that make it a superior interactive shell than more traditional shells like Bash. In this video, I will discuss a few…
Is there a difference in execution between executing a command and using an alias for the exact same command ?
I want to use a command semi often, so I put an alias for this command in my .bashrc but when I execute it, it throws an error that doesn't happen when I execute the command it is aliased directly.
I want to execute yt-dlp with a specific url in different directories, so I save the url in a "url.txt" file and execute the command
yt-dlp $(cat url.txt)
which works perfectly, but when I use the alias to the same command it can't read the url, is it the use of a subshell that isn't available in an alias ? would it be possible in a function ?
​
Also, unrelated, but to get the second to last line of a file, is there a better way than using
tail -n 2 foo | head -n 1
?
https://redd.it/13cwrib
@r_bash
I want to use a command semi often, so I put an alias for this command in my .bashrc but when I execute it, it throws an error that doesn't happen when I execute the command it is aliased directly.
I want to execute yt-dlp with a specific url in different directories, so I save the url in a "url.txt" file and execute the command
yt-dlp $(cat url.txt)
which works perfectly, but when I use the alias to the same command it can't read the url, is it the use of a subshell that isn't available in an alias ? would it be possible in a function ?
​
Also, unrelated, but to get the second to last line of a file, is there a better way than using
tail -n 2 foo | head -n 1
?
https://redd.it/13cwrib
@r_bash
Reddit
r/bash on Reddit: Is there a difference in execution between executing a command and using an alias for the exact same command ?
Posted by u/Mahkda - No votes and 1 comment
Kube-dialog update
Hi, kube-dialog got an update! Edit cmd added to cronjobs. And filtering updated, you can filter by status info using a template like this '#...'! Extremely handy!
https://preview.redd.it/b839g6fuquya1.png?width=883&format=png&auto=webp&v=enabled&s=3074e400a90f1fc32c4f2c4091e2781f9f5944fd
https://redd.it/13d2dhw
@r_bash
Hi, kube-dialog got an update! Edit cmd added to cronjobs. And filtering updated, you can filter by status info using a template like this '#...'! Extremely handy!
https://preview.redd.it/b839g6fuquya1.png?width=883&format=png&auto=webp&v=enabled&s=3074e400a90f1fc32c4f2c4091e2781f9f5944fd
https://redd.it/13d2dhw
@r_bash
GitHub
GitHub - vaniacer/kube-dialog: Dialog wrapper for kubectl on bash.
Dialog wrapper for kubectl on bash. Contribute to vaniacer/kube-dialog development by creating an account on GitHub.
Can anyone explain in English what these lines do?
I'm completely new to bash or Linux in general but have been using other languages many years ago so know the basics of strings etc.
I'm failing to understand these lines other than they are extracting something from one file and creating some variables. I can't find anything on -t or -p and I think "${1} might be an argument passed into this noscript. Other than that, I'm stumped.
`5 PREDICTION_START=\`/usr/bin/predict -t /home/bob/weather/predict/weather.tle -p "${1}" | head -1\``
`6 PREDICTION_END=\`/usr/bin/predict -t /home/bob/weather/predict/weather.tle -p "${1}" | tail -1\``
`7 MAXELEV=\`/usr/bin/predict -t /home/bob/weather/predict/weather.tle -p "${1}" | awk -v max=0 '{if($5>max){max=$5}}END{print max}'\``
https://redd.it/13eo6zr
@r_bash
I'm completely new to bash or Linux in general but have been using other languages many years ago so know the basics of strings etc.
I'm failing to understand these lines other than they are extracting something from one file and creating some variables. I can't find anything on -t or -p and I think "${1} might be an argument passed into this noscript. Other than that, I'm stumped.
`5 PREDICTION_START=\`/usr/bin/predict -t /home/bob/weather/predict/weather.tle -p "${1}" | head -1\``
`6 PREDICTION_END=\`/usr/bin/predict -t /home/bob/weather/predict/weather.tle -p "${1}" | tail -1\``
`7 MAXELEV=\`/usr/bin/predict -t /home/bob/weather/predict/weather.tle -p "${1}" | awk -v max=0 '{if($5>max){max=$5}}END{print max}'\``
https://redd.it/13eo6zr
@r_bash
Reddit
r/bash on Reddit: Can anyone explain in English what these lines do?
Posted by u/HemiBob - No votes and 1 comment
Bash noscript to send email from your terminal
https://owlhowto.com/bash-noscript-to-send-email-from-your-terminal/
https://redd.it/13erkg7
@r_bash
https://owlhowto.com/bash-noscript-to-send-email-from-your-terminal/
https://redd.it/13erkg7
@r_bash
OwlHowTo
Bash noscript to send email from your terminal
In this tutorial, we are going to write a bash noscript that will send an email from your terminal on Linux. The noscript is simple, it asks you enter 3 inputs, message, subject and the email address where you want to send this email to.
Script also checks if…
Script also checks if…
Text string is not working for me.
Mint+MATE-21.1: Hi, fairly new to Bash, but not programming as such. I want to insert a string into anther string so I only need to change the variable for a list of strings within a bunch of similar noscripts. e.g.
aname = "willow"
"cp -a /home/"$aname"/bakall/ /home/open/backups/all
"cp -a /home/"$aname"/baknew/ /home/open/backups/new
"cp -a /home/"$aname"/baklast/ /home/open/backups/last
As a test, I first created a basic noscript and set it as executable
#!/bin/bash
aname="willow"
echo $aname
When I run that, nothing shows up other than the CLI prompt again, so I tried
echo ${aname}
same again, just the CLI prompt, no errors -- nothing.
If I type those directly into the CL in 2-lines it works as expected and shows "willow"
What am I doing wrong in the noscript?
https://redd.it/13eur30
@r_bash
Mint+MATE-21.1: Hi, fairly new to Bash, but not programming as such. I want to insert a string into anther string so I only need to change the variable for a list of strings within a bunch of similar noscripts. e.g.
aname = "willow"
"cp -a /home/"$aname"/bakall/ /home/open/backups/all
"cp -a /home/"$aname"/baknew/ /home/open/backups/new
"cp -a /home/"$aname"/baklast/ /home/open/backups/last
As a test, I first created a basic noscript and set it as executable
#!/bin/bash
aname="willow"
echo $aname
When I run that, nothing shows up other than the CLI prompt again, so I tried
echo ${aname}
same again, just the CLI prompt, no errors -- nothing.
If I type those directly into the CL in 2-lines it works as expected and shows "willow"
What am I doing wrong in the noscript?
https://redd.it/13eur30
@r_bash
Reddit
r/bash on Reddit: Text string is not working for me.
Posted by u/oldSailor93 - No votes and 2 comments
I wrote a classic snake implementation in pure BASH v5.1+
https://github.com/wick3dr0se/snake
https://redd.it/13f0ipg
@r_bash
https://github.com/wick3dr0se/snake
https://redd.it/13f0ipg
@r_bash
GitHub
GitHub - wick3dr0se/snake: :snake: A super minimal TUI snake game written in pure BASH v5.1+
:snake: A super minimal TUI snake game written in pure BASH v5.1+ - wick3dr0se/snake
My first bash noscript, probably a disaster but apparently usable
https://github.com/Vdevelasco/quickCommand
I want to know what you guys think about this. Probably the style is going to be a mess, it works, but it's a mess. Any suggestions are welcome :)
https://redd.it/13f8gma
@r_bash
https://github.com/Vdevelasco/quickCommand
I want to know what you guys think about this. Probably the style is going to be a mess, it works, but it's a mess. Any suggestions are welcome :)
https://redd.it/13f8gma
@r_bash
GitHub
GitHub - Vdevelasco/quickCommand: A noscript for easily storing commands in a stack and using them faster. Designed for improving…
A noscript for easily storing commands in a stack and using them faster. Designed for improving speed. - GitHub - Vdevelasco/quickCommand: A noscript for easily storing commands in a stack and using th...
Inline man page as help.
A little noscript of mine showcasing inline man page for help. If call with
I hope someone finds it helpful.
#!/bin/bash
#> .TH PDF2OCR-5
#> .SH NAME
#> pdf2ocr \- convert PDF to PNG, OCR and extract text.
#> .SH SYNOPSIS
#> .B pdf2ocr
#> \fB\-h\fR
#> \fB\-l\fR \fIlang\fP
#> .IR files ...
#> .SH DESCRIPTION
#> .B pdf2ocr
#> This is a Bash noscript that converts PDF files to PNG, applies OCR using
#> \fITesseract\fP with a German language option, and extracts text to a text
#> file. It takes options -h for help and -l for the language code. It uses the
#> 'convert' command to convert PDFs to PNGs and then loops through each PNG
#> file to apply OCR and extract the text using the Tesseract command. Finally,
#> the noscript deletes the PNG files. It has a manpage for more information and
#> references the Tesseract documentation.
#> .SS OPTIONS
# Default to German for OCR
lang=deu
# Get Options
while getopts ":hl:" options
do case "${options}" in
#> .TP
#> .BR \-h
#> Get help in form of a manpage
#>
h)
sed -n 's/^#>\s//p' $0 | man -l -
exit 1;;
#> .TP
#> .BR \-l
#> The language code use by \fITesseract\fP to do character recognition.
#> defaults to "deu" for German.
l)
lang=${OPTARG}
shift;;
esac
shift
done
# Show short help, if no file is given.
if [ -z "$" ]
then
cat << EOF
Syntax: %s: -h -l lang Dateien\n
EOF
exit 0
fi
# Do the actual work:
for f in "$"
do
base=$(basename $(tr ' ' '_' <<< $f) .pdf)
convert -density 300x300 $f -colorspace RGB -density 300x300 $base.png
for png in $basepng
do
tesseract $png - --dpi 300 -l ${lang} >> $base.txt
rm $png
done
done
#> .SH "SEE ALSO"
#> tesseract(5)
https://redd.it/13fhkgb
@r_bash
A little noscript of mine showcasing inline man page for help. If call with
-h sed is used to extract the man page and display it with man -lI hope someone finds it helpful.
#!/bin/bash
#> .TH PDF2OCR-5
#> .SH NAME
#> pdf2ocr \- convert PDF to PNG, OCR and extract text.
#> .SH SYNOPSIS
#> .B pdf2ocr
#> \fB\-h\fR
#> \fB\-l\fR \fIlang\fP
#> .IR files ...
#> .SH DESCRIPTION
#> .B pdf2ocr
#> This is a Bash noscript that converts PDF files to PNG, applies OCR using
#> \fITesseract\fP with a German language option, and extracts text to a text
#> file. It takes options -h for help and -l for the language code. It uses the
#> 'convert' command to convert PDFs to PNGs and then loops through each PNG
#> file to apply OCR and extract the text using the Tesseract command. Finally,
#> the noscript deletes the PNG files. It has a manpage for more information and
#> references the Tesseract documentation.
#> .SS OPTIONS
# Default to German for OCR
lang=deu
# Get Options
while getopts ":hl:" options
do case "${options}" in
#> .TP
#> .BR \-h
#> Get help in form of a manpage
#>
h)
sed -n 's/^#>\s//p' $0 | man -l -
exit 1;;
#> .TP
#> .BR \-l
#> The language code use by \fITesseract\fP to do character recognition.
#> defaults to "deu" for German.
l)
lang=${OPTARG}
shift;;
esac
shift
done
# Show short help, if no file is given.
if [ -z "$" ]
then
cat << EOF
Syntax: %s: -h -l lang Dateien\n
EOF
exit 0
fi
# Do the actual work:
for f in "$"
do
base=$(basename $(tr ' ' '_' <<< $f) .pdf)
convert -density 300x300 $f -colorspace RGB -density 300x300 $base.png
for png in $basepng
do
tesseract $png - --dpi 300 -l ${lang} >> $base.txt
rm $png
done
done
#> .SH "SEE ALSO"
#> tesseract(5)
https://redd.it/13fhkgb
@r_bash
Reddit
r/bash on Reddit: Inline man page as help.
Posted by u/sebasTEEan - No votes and no comments
How to deal with valid constructions when set -e is in effect ?
Hi there !
I learned that is a good practice to use `set -eu` on my noscripts. Fine.
But how I should handle sittuations wher I expect a command return a non zero status and it is ok ?
For instance, smartctl may return a non zero status when there is some problem or when I want to test the return status of `grep -q`
echo $var | grep -q is_this_string_present;
if [[ "$?" == "0" //; ] then...
in both situations the noscript will exit silent, which is not desirable...in the code above, the `if` statement never gets executed.....you see ?
Talking about that, how to prevent the noscript exit silent when an legitm error occur ? (with `set -e`)
https://redd.it/13fk6uc
@r_bash
Hi there !
I learned that is a good practice to use `set -eu` on my noscripts. Fine.
But how I should handle sittuations wher I expect a command return a non zero status and it is ok ?
For instance, smartctl may return a non zero status when there is some problem or when I want to test the return status of `grep -q`
echo $var | grep -q is_this_string_present;
if [[ "$?" == "0" //; ] then...
in both situations the noscript will exit silent, which is not desirable...in the code above, the `if` statement never gets executed.....you see ?
Talking about that, how to prevent the noscript exit silent when an legitm error occur ? (with `set -e`)
https://redd.it/13fk6uc
@r_bash
Reddit
r/bash on Reddit: How to deal with valid constructions when set -e is in effect ?
Posted by u/marozsas - No votes and no comments
A Robust Bash Script for Partial Cloning of Git Repositories
Hello fellow Redditors,
I wanted to share a bash noscript I've been working on that makes it easy to perform a partial clone of a Git repository. This noscript is especially useful if you only want to clone a specific branch and directory, rather than the entire repository.
Here's how it works:
1. The noscript prompts you to input the Git repository URL. It validates the URL to ensure it's correct.
2. Next, it asks for the depth of the clone. This is a number that specifies how many recent commits you want to include in your clone. By default, the depth is 1, meaning only the most recent commit is included.
3. You're then asked to input the branch you want to checkout. The default branch is 'main'.
4. The noscript then performs a sparse clone of the repository. This type of clone doesn't download the entire repository content but only the history of specific files or directories, making the clone operation faster and the resulting local repository smaller.
5. After the clone is successful, the noscript enables sparse checkout, which allows you to limit which files and folders are checked out to your local working copy.
6. Finally, you're prompted to input the specific directory you want to checkout. By default, this is the root directory.
I hope you find this noscript useful! Feel free to modify it according to your needs and share your improvements. Looking forward to your feedback!
https://github.com/BalliAsghar/partial-clone
Happy coding!
https://redd.it/13flrua
@r_bash
Hello fellow Redditors,
I wanted to share a bash noscript I've been working on that makes it easy to perform a partial clone of a Git repository. This noscript is especially useful if you only want to clone a specific branch and directory, rather than the entire repository.
Here's how it works:
1. The noscript prompts you to input the Git repository URL. It validates the URL to ensure it's correct.
2. Next, it asks for the depth of the clone. This is a number that specifies how many recent commits you want to include in your clone. By default, the depth is 1, meaning only the most recent commit is included.
3. You're then asked to input the branch you want to checkout. The default branch is 'main'.
4. The noscript then performs a sparse clone of the repository. This type of clone doesn't download the entire repository content but only the history of specific files or directories, making the clone operation faster and the resulting local repository smaller.
5. After the clone is successful, the noscript enables sparse checkout, which allows you to limit which files and folders are checked out to your local working copy.
6. Finally, you're prompted to input the specific directory you want to checkout. By default, this is the root directory.
I hope you find this noscript useful! Feel free to modify it according to your needs and share your improvements. Looking forward to your feedback!
https://github.com/BalliAsghar/partial-clone
Happy coding!
https://redd.it/13flrua
@r_bash
GitHub
GitHub - BalliAsghar/partial-clone: This noscript is used to partial clone a git repository.
This noscript is used to partial clone a git repository. - GitHub - BalliAsghar/partial-clone: This noscript is used to partial clone a git repository.
Bash must not run in POSIX mode. Please unset POSIXLYCORRECT and try again.
I'm trying to run a ruby noscript that downloads the Homebrew [install.sh](https://install.sh) noscript and executes it, but I'm getting **Bash must not run in POSIX mode. Please unset POSIXLY\CORRECT and try again.
Did some little research on it, but still not clear what it is.
Can you give a little explanation on what it is, is it safe to unset it? and... What kind of "unexpected or different behavior" may I experience if unset?
https://redd.it/13fmc3l
@r_bash
I'm trying to run a ruby noscript that downloads the Homebrew [install.sh](https://install.sh) noscript and executes it, but I'm getting **Bash must not run in POSIX mode. Please unset POSIXLY\CORRECT and try again.
Did some little research on it, but still not clear what it is.
Can you give a little explanation on what it is, is it safe to unset it? and... What kind of "unexpected or different behavior" may I experience if unset?
https://redd.it/13fmc3l
@r_bash
Reddit
r/bash on Reddit: Bash must not run in POSIX mode. Please unset POSIXLY_CORRECT and try again.
Posted by u/aeum3893 - No votes and 1 comment
piu-piu
Massive piu-piu update!
Finally got some time to fix some bugs and merge starship branch into master. For those who unfamiliar with piu-piu it's a scroller game with text based graphics written on bash that runs in CLI terminals. It looks like this:
shoot them all
Enemies can drop some power-ups like health packs, you'll need them to stay alive a bit longer:
health pack
Ammo is depleting, grab some in the process to keep firing:
ammo pack
And gun upgrades x2, x3, x4 and x5:
gun x2
gun x3
gun x4
gun x5
Here is gun x5 in action)
x5 in action
But the small ones it's just the beginning, there is a big guy in the end, Boss)
boss fight
The game supports multiplayer modes co-op and duel. It uses netcat for this so it must be installed if you want to play with friend.
team play
duel
Spoiler, I'm planing to do the next chapter on Mars, here is the story:
here the story goes
See you on Mars!)
https://i.redd.it/utlgcdbxmgza1.gif
https://redd.it/13fw8ph
@r_bash
Massive piu-piu update!
Finally got some time to fix some bugs and merge starship branch into master. For those who unfamiliar with piu-piu it's a scroller game with text based graphics written on bash that runs in CLI terminals. It looks like this:
shoot them all
Enemies can drop some power-ups like health packs, you'll need them to stay alive a bit longer:
health pack
Ammo is depleting, grab some in the process to keep firing:
ammo pack
And gun upgrades x2, x3, x4 and x5:
gun x2
gun x3
gun x4
gun x5
Here is gun x5 in action)
x5 in action
But the small ones it's just the beginning, there is a big guy in the end, Boss)
boss fight
The game supports multiplayer modes co-op and duel. It uses netcat for this so it must be installed if you want to play with friend.
team play
duel
Spoiler, I'm planing to do the next chapter on Mars, here is the story:
here the story goes
See you on Mars!)
https://i.redd.it/utlgcdbxmgza1.gif
https://redd.it/13fw8ph
@r_bash
GitHub
GitHub - vaniacer/piu-piu-SH: This is an Old School horizontal scroller 'Shoot Them All' game in bash. With multiplayer modes team…
This is an Old School horizontal scroller 'Shoot Them All' game in bash. With multiplayer modes team and duel. You have to defeat 100 aliens to fight with Boss. I'm using ne...