From d5fd6ce0bad91b1cd2e76515e1259fa6c93665a7 Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 25 Oct 2021 07:42:50 +0000 Subject: added a program to convert a string with single-quotes into a shell-escaped version because writing that same sed regex over and over was a pain in the ass. also added a ssh handler. read before use. put them in Makefile --- sqesc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 sqesc.c (limited to 'sqesc.c') diff --git a/sqesc.c b/sqesc.c new file mode 100644 index 0000000..6d7ba23 --- /dev/null +++ b/sqesc.c @@ -0,0 +1,18 @@ +#include +#include + +int print_escaped(char *s) { + char *p=0; + for(p=strchr(s,'\'');p && s && *p && *s;p=strchr(s,'\'')) { + *p=0;//null out this single-quote + printf("%s",s); + printf("'\\''"); + s=p+1; + } + printf("%s",s); + return 0; +} + +int main(int argc,char *argv[]) { + return print_escaped(argv[1]); +} -- cgit v1.2.3