- This tutorial is a work in progress, expect more topics to be covered later
- Everything in this tutorial works in Repl.it, unless stated otherwise
- This is important to mention because it can overcome a suprising number of Repl.it's limitiations
- This tutorial assumes that you have basic knowledge of programming, specifically variables and functions (also known as procedures, methods)
What is Bash
The bash language is a shell scripting language, used for configuration, package management, automation of routine tasks and more. It is similar in purpose to powershell and (somewhat less so with) applescript.
Everything covered in this tutorial can be utilized in the Repl.it implemenation of Bash.
The (non comprehensive) list of known limitations (as of April 2019):
- unavailabilty sudo (for security reasons)
- aplay command (audio programming is not possible)
Basics of Bash
printf can be used to print to the terminal
printf if you need to format tabs or newline as it is more consistent across different terminals
Everything is a string
In bash everything is a
string and what they do is dependent on context.
Bash uses spaces as delimiters (seperators) so,
hello world is converted to the strings
'world'. Use single or double quotes to make it a single string, ie:
"hello world" or
The first string in a line is used as the command
"echo" "hello" are equivalent, but not
"echo hello" as the former are two strings and the latter is one string
It is important to be careful with spaces during assignment
$Hello tells Bash to replace the string
Hello with the variable
Reassignment & Constants
Flags are used to toggle specific options
Single hypens '-' are used for multiple single letter flags
Double hypens '-' are used for one multi-letter flag
Functions are declared as follows
Bash as a Control Language
Bash is a fundamental domain specific language in linux, and serves as it's control interface, like Apple's applescript and Window's powershell
It can be used to automate many routine tasks such as file management
Linux File Commands
The basic file system of Linux is structured as follows (Only relevant files are shown)
The starting directory is called the root directory '
/', which is approximately equivalent to
C:\ on windows
File Command are
Compiling with GCC
@Scoder12 had provided the general idea of using Bash to compile programs
GCC, Make and Git and installed in Repl.it
Makefiles can be used to reduce compilation time by only compiling the changed files
Default Linux libraries (ncurses.h, unistd.h) are already included in Repl.it
Any unavailable libraries (SDL2, SFML, ...) can be downloaded from their respective sites and then uploaded to Repl.it to be used in your project or cloned and compiled via git
GCC can compile C or C++ to assembly
It can also be used to access git
Here is a good post on using git by @eankeen
I assume we can’t have a way to do the equivalent of a “sudo apt-install g++”? In order to work with something like an assembly file with NASM/YASM.
@alexvillarreal If @SigmaPhi is correct, it is installed but if you have and dependencies you need to install use a polygott repl which is beta language that allows you to install things using a command called
install-pkg which is basically
sudo apt-get install. It is a makefile, not a bash script though.
@SigmaPhi maybe you should put something like this in the tutorial
I am a repl.it helper. If this is a good tip, please upvote.
@Scoder12 Cool, I didn't know about the install-pkg command. I had seen your proof of concept of ncurses on C, and was wondering what the polygott repl was. I didn't see them listed in the languages (It seems that it is unlisted, are there any other beta languages btw ?)
Makefiles are pretty relevant, so I will be adding more info. Also does Repl.it have a WYSIWYG markdown editor ? (That would be a cool feature!).
@SigmaPhi nah, it's just a bash repl. There is a bug post, and it had an answer saying that the bash repl is the same as the polygott repl. All you have to do is add a Makefile. You can still use install-pkg. If you really want to use a polygott repl, even though you don't need to, just use https://repl.it/new/polygott_beta . So no, it is not removed.