できるだけ標準・慣例に従い,また自己文書化及び単一実行可能を心掛けた。
Last active
May 2, 2020 00:00
-
-
Save cmplstofB/786bc35298efaa0d3ce9f2addcc6bbba to your computer and use it in GitHub Desktop.
様々なファイルの雛形
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*/ 2>&- > /dev/null || : | |
exec bc -l "$0" | |
exit $? | |
*/ | |
"hello" | |
quit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if 0 | |
<<. make -f - run distclean | |
.POSIX: | |
.SUFFIXES: | |
PROGNAME = $(basename ${0%.*}) | |
BASEDIR = $(test "${0##*[^.]/}" = "$0" && pwd || (cd "${0%/*}" && pwd)) | |
SRCFILE = \$(BASEDIR)/\$(PROGNAME).c | |
EXEFILE = \$(BASEDIR)/\$(PROGNAME) | |
CC = c99 | |
CFLAGS = -g \\ | |
-Wall \\ | |
-Wextra \\ | |
-Wpedantic \\ | |
-Wshadow \\ | |
-Werror | |
all: \$(EXEFILE) | |
\$(EXEFILE): \$(SRCFILE) | |
@\$(CC) \$(CFLAGS) -o \$@ \$< | |
run: \$(EXEFILE); @\$< $@ | |
distclean: | |
-@rm -f -r \$(EXEFILE) | |
. | |
exit $? | |
#endif | |
#define _XOPEN_SOURCE 700 | |
#include <assert.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <inttypes.h> | |
#include <math.h> | |
int main(void) { | |
printf("円周率πは約%gです。\n", M_PI); | |
uintmax_t uintmax = UINTMAX_MAX; | |
printf("本機構での符号無し整数の最大値は%"PRIuMAX"です。\n", uintmax); | |
exit(EXIT_SUCCESS); | |
assert(0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
<<. make -f - run distclean | |
.POSIX: | |
.SUFFIXES: | |
PROGNAME = $(printf '%s' "$0" | | |
sed -e 's/\(.*\)\.[^.]*/\1/') | |
BASEDIR = $(pwd) | |
SRCFILE = \$(BASEDIR)/\$(PROGNAME).pas | |
BINFILE = \$(BASEDIR)/\$(PROGNAME) | |
PC = fpc | |
PFLAGS = -vn -Miso | |
all: \$(BINFILE) | |
\$(BINFILE): \$(SRCFILE) | |
@\$(PC) \$(PFLAGS) \$< > '/dev/null' 2> '/dev/null' | |
run: \$(BINFILE); @\$< | |
clean: | |
-@rm -f \$(PROGNAME).o | |
distclean: clean | |
-@rm -f \$(BINFILE) | |
. | |
exit $? | |
} | |
PROGRAM slfbld(output); | |
BEGIN | |
writeln('Hello, Pascal!'); | |
END. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""":" . | |
exec python3 "$0" "$@" | |
""" | |
__doc__ = """このコマンドの要約. | |
複数行の | |
説明。 | |
""" | |
__author__ = "B̅ <[email protected]>" | |
__version__ = "0.1.0" | |
__date__ = "2019-06-30" | |
import sys | |
import argparse | |
def main(args): | |
"""「Hello, Python!」と出力する.""" | |
print("Hello, Python!") | |
parser = argparse.ArgumentParser() | |
parser.parse_args() | |
if __name__ == '__main__': | |
sys.exit(main(sys.argv[1:])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
_METADATA='@prefix : <http://purl.org/net/ns/doas#>. <> a :Script; | |
:一行説明 "シェルスクリプトの雛形"; | |
:作成日 "YYYY-MM-DD"; | |
:公開版 [:版 "0.1.0"; :作成日 "YYYY-MM-DD"]; | |
:作成者 "cmplstofB"; | |
:権利 "ⓒ 2019 cmplstofB"; | |
:ライセンス <http://www.wtfpl.net/txt/copying/>; | |
:依存関係 "".' | |
issu() { set -- | |
#@ 実行している利用者が特権利用者かどうかを判定 | |
#@ Usage: issu | |
test $(id -u) -eq 0 || return 77 | |
} | |
assert() { set -- "$1" $? | |
#@ !! 暫定 | |
#@ 表明を実行する | |
#@ Usage: assert <expr> | |
#@ Operands: | |
#@ <expr> 表明する式 | |
#@ (test(1)ユーティリティの被演算子) | |
if ! ${DEBUG+:} false || test $1; then | |
return $2 | |
else | |
printf '%s: 表明‘%s’が失敗しました。\n' "${0##*/}" "$1" | |
kill -s ABRT $$ | |
fi | |
} >&2 | |
die() { set -- "$1" ${2:-$?} | |
#@ 文言を表示して不成功する | |
#@ 使用法: die <message> [<exit_status>] | |
#@ 被演算子: | |
#@ <message> 表示する文言 | |
#@ <exit_status> 返り値 | |
#@ (既定は直前の返り値か,もしもそれが0なら1) | |
printf '%s: [\033[1;31m誤り\033[22;39m] %s\n' "${0##*/}" "$1" | |
exit $(($2?$2:1)) | |
} >&2 | |
print_help() { set -- "${1:-}" | |
[ "$1" = 'stderr' ] && exec 1>&2 | |
printf '\033[36m使用法\033[39m: '; { | |
printf '\033[1m%s\033[22m' "${0##*/}" | |
printf ' \033[4m%s\033[24m' \ | |
'<opd>' | |
printf ' [\033[1m%s\033[22m \033[4m%s\033[24m]' \ | |
'-o' '<opt>' | |
printf '\n' | |
} | |
printf '\033[36m被演算子\033[39m\n'; { | |
printf '\t\033[4m%s\033[24m\t%s\n' \ | |
'<opd>' '被演算子の例' | |
} | expand -t '2,34' | |
printf '\033[36mオプション\033[39m\n'; { | |
printf '\t\033[1m%s\033[22m \033[4m%s\033[24m\t%s\n' \ | |
'-o' '<opt>' '(任意)オプションの例' \ | |
'-h' '' 'この手引きを表示して終了。' | |
} | expand -t '2,34' | |
} | |
main() { | |
set -o errexit | |
set -o nounset | |
set -o noclobber | |
umask 0022 | |
export PATH="$(command -p getconf PATH)${PATH:+:$PATH}" | |
while getopts o:h opt; do | |
case $opt in | |
h) print_help; exit;; | |
o) _opd="$OPTARG";; | |
?) | |
print_help stderr | |
die '引数を認識できません。' 22 | |
;; | |
esac | |
done; shift $((OPTIND - 1)) | |
} | |
main "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%= 2>&- /dev/null || iffalse() { :; } | |
\iffalse | |
<<. make -f - run clean | |
.POSIX: | |
.SUFFIXES: | |
PROGNAME = $(basename ${0%.*}) | |
BASEDIR = $(test "${0##*[^.]/}" = "$0" && pwd || (cd "${0%/*}" && pwd)) | |
SRCFILE = \$(BASEDIR)/\$(PROGNAME).tex | |
PDFFILE = \$(BASEDIR)/\$(PROGNAME).pdf | |
TEX = ptex2pdf | |
TEXFLAGS = -e -u -ot '\$(TEXFLAGS_OT)' -od '\$(TEXFLAGS_OD)' --output-directory=. | |
TEXFLAGS_OT = --file-line-error \\ | |
--halt-on-error \\ | |
--interaction=nonstopmode | |
TEXFLAGS_OD = -f uptex-ipaex.map | |
PDFVIEWER = texdoc --just-view | |
all: \$(PDFFILE) | |
\$(PDFFILE): \$(SRCFILE) | |
@\$(TEX) \$(TEXFLAGS) \$< > '/dev/null' 2> '/dev/null' | |
run: \$(PDFFILE); @\$(PDFVIEWER) \$< | |
clean: | |
-@rm -f -r \$(PROGNAME).log | |
. | |
exit $? | |
$ | |
\fi | |
%% PDFの版 | |
\special{pdf:minorversion 7}% | |
%% 文書情報 | |
\immediate\special{pdf:tounicode UTF8-UTF16 [/ActualText]}% | |
\special{pdf:docview << /Lang (ja) >>}% | |
\special{pdf:docinfo << | |
/Title (自己ビルドできるε-upTeXの文書) | |
/Author (B̅ (cmplstofB)) | |
/Subject (ε-upTeXによるPDF文書の例) | |
/Keywords (ε-upTeX;PDF) | |
/Creator (ε-upTeX (3.14159265-% | |
p\number\ptexversion.\number\ptexminorversion\ptexrevision-% | |
u\number\uptexversion\uptexrevision-% | |
\number\epTeXversion-% | |
\number\eTeXversion\eTeXrevision)) | |
>>}% | |
\special{pdf:docview << /ViewerPreferences << | |
/DisplayDocTitle true | |
>> >>}% | |
%% 字体 | |
\font\seventeenbf=cmb10 at 17pt\relax | |
\immediate\special{pdf:mapline uphminbn-h unicode :0:NotoSerifCJK-Bold.ttc -l jp04}% | |
\font\seventeenbmc=uphminbn-h at 17pt\relax | |
\def\seventeenbvarepsiron{{\font\seventeenbgr=fcmbgr at 17pt\seventeenbgr e}} | |
%% 本文 | |
\centerline{% | |
\seventeenbf\seventeenbmc 自己ビルドできる\seventeenbvarepsiron-up\kern-.05em\TeX の文書} | |
\medskip | |
\centerline{$\bar B$ ({\tt cmplstofB})} | |
\bigskip | |
こんにちは,\TeX! | |
$$ | |
E = mc^2 | |
$$ | |
\bye |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE html> | |
<html lang="ja" xml:lang="ja" | |
xmlns="http://www.w3.org/1999/xhtml" | |
> | |
<head> | |
<meta charset="UTF-8"/> | |
<meta name="viewport" content="width=device-width, initial-scale=1"/> | |
<title>表題 ❙ サイト名</title> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment