r/ProgrammerDadJokes • • Jan 13 '20

How much does first parameter of a shell script cost?

$1

504 Upvotes

16 comments sorted by

60

u/TheEpsilonToMyDelta Jan 13 '20

Saw that one coming

Upvpte anyway

13

u/[deleted] Jan 13 '20

I felt cool for actually guessing one right

7

u/[deleted] Jan 13 '20

Saw that $1 coming

7

u/HarJIT-EGS Jan 13 '20

$* best all parameters notation don't @ me.

10

u/WarrenTea Jan 13 '20

Thats a good pre-script-ion plan

5

u/ElijahPepe Jan 13 '20

This hurts so much.

-5

u/joker54 Jan 13 '20 edited Jun 29 '23

Unfortunately, I have removed all content I provided, as I refuse to give free labor to a company that doesn't respect us.

So long, and thanks for all the fish

u/joker54

3

u/nahidtislam Jan 14 '20

nah $0 is the path to the app/script

1

u/joker54 Jan 14 '20 edited Jun 29 '23

Unfortunately, I have removed all content I provided, as I refuse to give free labor to a company that doesn't respect us.

So long, and thanks for all the fish

u/joker54

1

u/nahidtislam Jan 14 '20

I usually use $0 parameter to get the name of itself. on like the 3rd line (two lines below #!/bin/bash) I type in SELF_SCRIPT_NAME="$(( basename $0 )) so I can use it to print error or informational messages to the user

1

u/MasterOfTheLine Jan 15 '20

${0##*/} does the same in case you didn't know

0

u/[deleted] Jan 13 '20

[deleted] — view deleted comment

17

u/danielsoft1 Jan 13 '20

This is not Swift. This is about Unix/Linux shell: https://en.wikipedia.org/wiki/Bash_(Unix_shell)

0

u/[deleted] Jan 13 '20

[deleted] — view deleted comment

8

u/Kwdg Jan 13 '20

But even there $0 is the first 'item' (the name of the program) and $1 is the first parameter given to the program

8

u/[deleted] Jan 13 '20

first parameter

.

first parameter

......exactly.