What is the meaning of the following which is on the top of linux script
#!/bin/bash
return &> /dev/null
A symlink (also called a symbolic link) is a type of file in Linux that points to another file or a folder on your computer. Symlinks are similar to shortcuts in Windows. Some people call symlinks "soft links" – a type of link in Linux/UNIX systems – as opposed to "hard links."
In your Linux file system, a link is a connection between a file name and the actual data on the disk. There are two main types of links that can be created: "hard" links, and "soft" or symbolic links.
Links are used in many instances: Sometimes to create a convenient path to a directory buried deep within the file hierarchy; other uses for links include: Linking libraries. Making sure files are in constant locations (without having to move the original) Keeping a “copy” of a single file in multiple locations.
Use the -s option to create a soft (symbolic) link. The -f option will force the command to overwrite a file that already exists. Source is the file or directory being linked to. Destination is the location to save the link – if this is left blank, the symlink is stored in the current working directory.
The line is to protect users from sourcing the script.
When the script is run (not sourced but run), the script will proceed to the next lines until the end of file.
When the script is sourced, the script will just return and do nothing.
return
is supposed to return value from bash function.
When used exactly like in your example but without &> /dev/null
, it is invalid use because return
does not belong to body of bash function, and would print:
line 2: return: can only `return' from a function or sourced script
However, somebody decided to hide that error message by piping output to /dev/null
.
In other words, this all does not make much sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With