Branch:
bash
Fenrir ID:bash
Points:100
Your solution must be located at bash:
[folder] ...
├─ [folder] bash
│ ├─ [file text] column.sh
│ ├─ [file text] line-counter.sh
│ ├─ [file text] prod.sh
│ ├─ [file text] stackd.sh
│ ├─ [file text] sym-diff.sh
│ └─ [file text] wrapper.sh
└─ [folder] .gitFile:
prod.sh
You have to calculate the dot product of two vectors.
The input (stdin) consists of two lines (two vectors). Both vectors must contain only integers, a space character is used as a separator.
When exiting due to an error, you must provide a description. The description must be clear and concise.
- Non-numeric symbols
-
Exit code: 11
- Mismatched number of elements
-
Exit code: 10
File:
stackd.sh
You have to reimplement pushd-popd-dirs utils in bash. The script must provide a function stackd which can be used to replace pushd-popd-dirs.
You CANNOT use any of those commands! To switch directories use
cd.
stackd CMD
CMD:
init Initialise the directory stack with PWD as the first element
list Display the entire stack (dirs).
Example: 'top middle bottom'
pop Pop a dir from the stack and switch to the new top directory.
The second directory must be displayed (popd)
push DIR Push DIR onto the stack and switch to it (pushd)When exiting due to an error, you must provide a description. The description must be clear and concise.
- Invalid number of arguments
-
-
push: exit code 11 -
pop: exit code 21 -
list: exit code 31 -
init: exit code 41
-
- Invalid CMD
-
Exit code: 6
- DIR in push is not a directory
-
Exit code: 12
- Not enough elements to pop
-
Exit code: 22
- The directory does not exist when pop
-
Exit code: 23
File: column.sh
You have to reimplement column util in bash.
You CANNOT use
columnin your implementation!
column.sh [-s SEPARATOR]
OPTIONS:
-s SEPARATOR The character used to split the rows.
The default value is ' ' (a space)The semantics of your script must be the same as that of column -s SEPARATOR -t from utils-linux, except for the last column: it must not be followed by spaces.
When exiting due to an error, you must provide a description. The description must be clear and concise.
- Invalid option
-
Exit code: 1
- Missing the value for
-s -
Exit code: 2
- Non-matching number of elements
-
Exit code: 3
File:
sym-diff.sh
You have to provide a function sym-diff that takes two arguments (the names of two arrays) and calculates their symmetric difference.
Each array represents a set of numbers so its element uniqueness is guaranteed.
The result (stdout) must be sorted in descending order.
|
Important
|
You cannot access arrays elements directly, use other commands that manipulate the data to achieve the goal. You are allowed only to use ${_[@]} at the beginning of your function to retrieve the data.
|
|
Tip
|
The task can be solved with a single pipeline (… | …)
|
ar=(1 2)
ra=(1 3)
val=()
while read -r line; do val+=("$line"); done < <(sym-diff ar ra)val is expected to be equal to (3 2)
File:
wrapper.sh
|
Note
|
Spoiler alert! You are going to find and study some new information yourself during this task. |
Create a custom wrapper script which can be used as a shebang.
- Handle
SIGTERMsignal -
Print
No no no, mr fish!to stdout and logSIGTERM detectedinWARNmode. You must prevent the script from termination. - Track the inner script execution
-
-
Log each command that is executed in
DEBUGmode -
When the command is
echo, it must be logged inERRORmode and the wrapper must preventechofrom being executed.
-
- Logging
-
Log format:
MODE TIMESTAMP MESSAGE-
MODE- find some information about log modes yourself -
TIMESTAMP- the timestamp of the log. Format:YYYY-MM-DD HH:MM:SS
-
All logs must be written to the file $LOG_FILE (passed as an env variable)
Inner script:
#! wrapper.sh
echo 3 4 5 6
ls -l | grep total | cut -f1 -d' 'stdout: total
stderr:
$LOG_FILE:
ERROR 2026-02-26 11:14:51 echo 3 4 5 6
DEBUG 2026-02-26 11:14:51 ls -l
DEBUG 2026-02-26 11:14:51 grep total
DEBUG 2026-02-26 11:14:51 cut -f1 -d' '|
Caution
|
Tests might fail if you run them at 23:59:_ (The date might change) |
|
Caution
|
Use fenrir rund if your system’s language is not English!
|
|
Tip
|
Read about special signals in bash for tracking the execution. |
|
Tip
|
You might need to use set and shopt commands to set up the execution.
|
File:
line-counter.sh
You have to implement a script which calculates the LOC metric of a project. (LOC is Lines Of Code)
line-counter.sh PROJECT_ROOT [OPTIONS]...
OPTIONS:
-i, --include FILE Calculate LOC only for the files whose extensions are
declared in FILE. FILE must follow the CSV format
-e, --exclude FILE Exclude files whose extension are declared in FILE.
FILE must follow the CSV format
When both options are used, -e excludes files from the set selected by -i.Since the CSV format allows different separators, your script must automatically detect which one is used. It is guaranteed that the extensions consist of alphanumeric characters and maybe dots or spaces.
The project is licensed under the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
© 2026-present Iwan Kalinin <koefic.cien@gmail.com>