From f08c1ac3f7c4eda11eaccdea8fb6991230be8e56 Mon Sep 17 00:00:00 2001 From: askiiart Date: Wed, 23 Aug 2023 11:54:46 -0500 Subject: [PATCH] Add stuff --- daily-use-pcs/fedora/setup-git.bash | 2 +- random-bash.md | 11 ++++++++++- test.bash | 4 ++-- zsh/zsh-setup.bash | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) mode change 100644 => 100755 random-bash.md diff --git a/daily-use-pcs/fedora/setup-git.bash b/daily-use-pcs/fedora/setup-git.bash index 8a56103..425777d 100755 --- a/daily-use-pcs/fedora/setup-git.bash +++ b/daily-use-pcs/fedora/setup-git.bash @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Exit if there's an error set -e # Modify constants as needed diff --git a/random-bash.md b/random-bash.md old mode 100644 new mode 100755 index ce4ea8a..344e402 --- a/random-bash.md +++ b/random-bash.md @@ -49,9 +49,18 @@ echo "Package manager: ${PM}" This exits with and error message if it's run as root. ```bash -#!/bin/bash +#!/usr/bin/env bash if [ $(whoami) != "root" ]; then >&2 echo Rerun as non-root user exit 1 fi +``` + +## Output to stderr + +```bash +#!/usr/bin/env bash +# Put `>&2` at beginning or end of line to output to stderr +>&2 echo "This goes to stderr" +echo "This goes to stdout" ``` \ No newline at end of file diff --git a/test.bash b/test.bash index 46361b3..88aa31f 100755 --- a/test.bash +++ b/test.bash @@ -1,5 +1,5 @@ -#!/bin/bash -command_exists() { type "$1" &> /dev/null; } +#!/usr/bin/env bash +type "$1" &> /dev/null; } if command_exists "apt-get"; then PM="apt-get" diff --git a/zsh/zsh-setup.bash b/zsh/zsh-setup.bash index e6f534b..66af0cb 100755 --- a/zsh/zsh-setup.bash +++ b/zsh/zsh-setup.bash @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Exit if there's an error set -e declare -A osInfo;