shelllings

a practical way to learn shell
git clone https://git.davidvoz.net/shelllings.git
Log | Files | Refs | README | LICENSE

commit d3d5de8a2fff6e399cfc6eb52dcfbda4910b504e
parent f4a433becc2400b680fdd86dbc850a9059f69644
Author: David Voznyarskiy <31452046-davidvoz@users.noreply.gitlab.com>
Date:   Fri,  2 Jan 2026 23:40:13 -0800

exercise 29 gzip added

Diffstat:
Aexercises/29_gzip.sh | 9+++++++++
Atests/29_gzip.sh | 28++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/exercises/29_gzip.sh b/exercises/29_gzip.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# gzip (gunzip) is a GNU file compression and expansion tool that comes +# with most linux distrobutions. Use the --help option to know how to +# compress the LICENSE file into a new file LICENSE.gz, leaving LICENSE +# unchanged. If successful, don't worry about having to remove the .gz +# file, shelllings.sh will take care of that. + + diff --git a/tests/29_gzip.sh b/tests/29_gzip.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -eu +RED="\033[31m" +GREEN="\033[32m" +RESET="\033[0m" + +cleanup() { + [ -f "LICENSE.gz" ] && rm LICENSE.gz +} +trap cleanup EXIT + +failed() { + printf "${RED}Failed${RESET}\n" + exit 1 +} + +sh exercises/29_gzip.sh || failed + +[ -s LICENSE.gz ] || failed +[ -s LICENSE ] || failed + +leis_size=$(stat -c%s LICENSE) +gz_size=$(stat -c%s LICENSE.gz) + +[ $leis_size -gt $gz_size ] || failed + +printf "${GREEN}Passed${RESET}\n"