#!/usr/bin/env slsh private variable Sign_Cmd = "gpg --armor --detach-sign" + " --comment \"See http://www.jedsoft.org/signature.html for more information\"" + " --passphrase-fd 0 --output '%s' '%s'"; private variable Pass_Phrase = NULL; private define sign_file (file) { if (NULL == stat_file (file)) { () = fprintf (stderr, "Unable to stat %s\n", file); return -1; } variable sig_file = file + ".sig"; variable cmd = sprintf (Sign_Cmd, sig_file, file); variable fp = popen (cmd, "w"); if (fp == NULL) { () = fprintf (stderr, "Unable to sign %s-- skipped\n", file); return -1; } if ((bstrlen (Pass_Phrase) != fwrite (Pass_Phrase, fp)) or (-1 == fflush (fp)) or (-1 == fclose (fp))) { () = fprintf (stderr, "Failed to write the passhrase\n"); return -1; } return 0; } define slsh_main () { if (__argc < 2) { () = fprintf (stderr, "Usage: %s files...\n", __argv[0]); exit (1); } Pass_Phrase = slsh_readline_noecho ("Enter Passphrase:"); _for (1, __argc-1, 1) { variable i = (); variable file = __argv[i]; if (-1 == sign_file (file)) () = fprintf (stderr, "Error signing %s -- skipping it\n", file); } exit (0); }