config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit 4d544cce546f0c1deefd67f5f28c9a82fc2f143b
parent ee751ac304de54ea70b2873323eabdcb4cf2fed4
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Wed, 21 Jul 2021 18:55:44 -0700

Add various scripts

These scripts (with the exception of cdec, which I just wrote) have
been useful to me. I probably should have added them a long time
ago.

Diffstat:
Alocal/bin/.local/bin/backup3 | 6++++++
Alocal/bin/.local/bin/ccom | 19+++++++++++++++++++
Alocal/bin/.local/bin/cdec | 24++++++++++++++++++++++++
Alocal/bin/.local/bin/chead | 14++++++++++++++
Alocal/bin/.local/bin/dl | 6++++++
Alocal/bin/.local/bin/src | 7+++++++
6 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/local/bin/.local/bin/backup3 b/local/bin/.local/bin/backup3 @@ -0,0 +1,6 @@ +#!/bin/sh +# Copyright 2021 Jacob R. Edwards +# License: GPLv3 +# Third revision of a simple backup script + +exec openrsync -av --del "$HOME" "$@" diff --git a/local/bin/.local/bin/ccom b/local/bin/.local/bin/ccom @@ -0,0 +1,19 @@ +#!/usr/bin/awk -f +# Copyright 2021 Jacob R. Edwards +# License: GPLv3 +# Display C-style comments + +/\/\*/ { + inside = 1; +} + +inside { + if (header) + printf("%s:%d\t%s\n", FILENAME, FNR, $0); + else + print; +} + +/\*\// { + inside = 0 +} diff --git a/local/bin/.local/bin/cdec b/local/bin/.local/bin/cdec @@ -0,0 +1,24 @@ +#!/usr/bin/sed -Ef +# Copyright 2021 Jacob R. Edwards +# License: GPLv3 +# Create C function declarations out of their definitions +# +# Function definitions of the form +# ^return type[ \n]func([^{]*{$ +# are output in the form +# return type func(param, ...); + +/^[a-zA-Z_]/ ! d + +: a +/;/ d +/{$/ ! { + N + b a +} +/\)/ ! d + +s/[ \n]+/ /g +s/\) ?{.*$/);/ +s/\* /*/ +s/(.*) (\**[a-zA-Z_]+)\(/\1 \2(/ diff --git a/local/bin/.local/bin/chead b/local/bin/.local/bin/chead @@ -0,0 +1,14 @@ +#!/usr/bin/awk -f +# Copyright 2021 Jacob R. Edwards +# License: GPLv3 +# Extract C function declarations from definitions +# +# Obsoleted by cdec (although kept in case of cdec failure) + +/^[a-zA-Z_]/ { + var = $0; + getline; + if (match($0, /\)$/) <= 0) + next; + printf("%s\t%s;\n", var, $0); +} diff --git a/local/bin/.local/bin/dl b/local/bin/.local/bin/dl @@ -0,0 +1,6 @@ +#!/bin/sh +# Copyright 2021 Jacob R. Edwards +# License: GPLv3 +# Write given resources to their basenames using curl(1) + +curl -SsL -$(jot -b O | tr -d '\n') "$@" diff --git a/local/bin/.local/bin/src b/local/bin/.local/bin/src @@ -0,0 +1,7 @@ +#!/bin/sh +# Copyright 2021 Jacob R. Edwards +# License: GPLv3 +# List C source files in the current directory + +ls *.c | sort | tr '\n' ' ' | sed 's/ $/\ +/'