From 39a6cbe67d3c482784e5cecc1fba5e4b65151b21 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 4 Mar 2024 13:07:06 -0700 Subject: [PATCH] Improve samples organization, add check script --- .../x-shellscript.sh} | 0 samples/check.sh | 27 +++++++++++++++++++ .../{text_markdown.md => text/markdown.md} | 0 samples/text/plain.txt | 1 + samples/{text_rust.rs => text/rust.rs} | 0 samples/{text_x-chdr.h => text/x-chdr.h} | 0 samples/{text_x-csrc.c => text/x-csrc.c} | 0 7 files changed, 28 insertions(+) rename samples/{application_x-shellscript.sh => application/x-shellscript.sh} (100%) create mode 100755 samples/check.sh rename samples/{text_markdown.md => text/markdown.md} (100%) create mode 100644 samples/text/plain.txt rename samples/{text_rust.rs => text/rust.rs} (100%) rename samples/{text_x-chdr.h => text/x-chdr.h} (100%) rename samples/{text_x-csrc.c => text/x-csrc.c} (100%) diff --git a/samples/application_x-shellscript.sh b/samples/application/x-shellscript.sh similarity index 100% rename from samples/application_x-shellscript.sh rename to samples/application/x-shellscript.sh diff --git a/samples/check.sh b/samples/check.sh new file mode 100755 index 0000000..5819df9 --- /dev/null +++ b/samples/check.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e + +for file in */* +do + filetype="$(xdg-mime query filetype "${file}")" + if [ -z "${filetype}" ] + then + echo "${file}: no filetype found" + exit 1 + fi + if [ "${file%.*}" != "${filetype}" ] + then + echo "${file} is not named according to filetype ${filetype}" + exit 1 + fi + + default="$(xdg-mime query default "${filetype}")" + if [ -z "${default}" ] + then + echo "${file}: ${filetype}: no default application found" + exit 1 + fi + + echo "${file}: ${filetype}: ${default}" +done diff --git a/samples/text_markdown.md b/samples/text/markdown.md similarity index 100% rename from samples/text_markdown.md rename to samples/text/markdown.md diff --git a/samples/text/plain.txt b/samples/text/plain.txt new file mode 100644 index 0000000..b5da95d --- /dev/null +++ b/samples/text/plain.txt @@ -0,0 +1 @@ +This is a plain text file. diff --git a/samples/text_rust.rs b/samples/text/rust.rs similarity index 100% rename from samples/text_rust.rs rename to samples/text/rust.rs diff --git a/samples/text_x-chdr.h b/samples/text/x-chdr.h similarity index 100% rename from samples/text_x-chdr.h rename to samples/text/x-chdr.h diff --git a/samples/text_x-csrc.c b/samples/text/x-csrc.c similarity index 100% rename from samples/text_x-csrc.c rename to samples/text/x-csrc.c