Skip to content

Commit 3c2f46f

Browse files
committed
bash programming patterns
1 parent 258e7f3 commit 3c2f46f

File tree

7 files changed

+14
-6
lines changed

7 files changed

+14
-6
lines changed

agd

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
apt-get --download-only --force-yes -y -u dist-upgrade
2+
sudoifnotroot apt-get --download-only --force-yes -y -u dist-upgrade

agdu

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
apt-get -u $* dist-upgrade
2+
sudoifnotroot apt-get -u $* dist-upgrade

agi

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
apt-get -u install $*
2+
sudoifnotroot apt-get -u install $*

agp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
apt-get purge $*
2+
sudiofnotroot apt-get purge $*

agr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
apt-get remove $*
2+
sudoifnotroot apt-get remove $*

agu

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
apt-get update
2+
sudoifnotroot apt-get update

sudoifnotroot

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
CMD="$*"
3+
4+
if [ $UID == 0 ]; then
5+
$CMD
6+
else
7+
sudo $CMD
8+
fi

0 commit comments

Comments
 (0)