Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Aug 2017 18:01:28 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r322177 - head/usr.bin/indent
Message-ID:  <201708071801.v77I1SIG020914@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Mon Aug  7 18:01:27 2017
New Revision: 322177
URL: https://svnweb.freebsd.org/changeset/base/322177

Log:
  Respect SIMPLE_BACKUP_SUFFIX environment variable in indent(1)
  
  Instead of using a non-configurable ".BAK" suffix, respect the
  SIMPLE_BACKUP_SUFFIX environment variable also used by patch(1). This
  simplifies cleanup operations in some patch/indent workflows.
  
  Reviewed by:	cem (earlier version), emaste, pstef
  Approved by:	emaste (mentor)
  Differential Revision:	https://reviews.freebsd.org/D10921

Modified:
  head/usr.bin/indent/indent.1
  head/usr.bin/indent/indent.c

Modified: head/usr.bin/indent/indent.1
==============================================================================
--- head/usr.bin/indent/indent.1	Mon Aug  7 17:30:22 2017	(r322176)
+++ head/usr.bin/indent/indent.1	Mon Aug  7 18:01:27 2017	(r322177)
@@ -30,7 +30,7 @@
 .\"	@(#)indent.1	8.1 (Berkeley) 7/1/93
 .\" $FreeBSD$
 .\"
-.Dd July 25, 2017
+.Dd August 7, 2017
 .Dt INDENT 1
 .Os
 .Sh NAME
@@ -119,7 +119,10 @@ If
 is named
 .Sq Pa /blah/blah/file ,
 the backup file is named
-.Sq Pa file.BAK .
+.Sq Pa file.BAK
+by default. The extension used for the backup file may be overridden using the
+.Ev SIMPLE_BACKUP_SUFFIX
+environment variable.
 .Pp
 If
 .Ar output-file

Modified: head/usr.bin/indent/indent.c
==============================================================================
--- head/usr.bin/indent/indent.c	Mon Aug  7 17:30:22 2017	(r322176)
+++ head/usr.bin/indent/indent.c	Mon Aug  7 18:01:27 2017	(r322177)
@@ -71,6 +71,8 @@ const char *in_name = "Standard Input";	/* will always
 					 * file */
 const char *out_name = "Standard Output";	/* will always point to name
 						 * of output file */
+const char *simple_backup_suffix = ".BAK";	/* Suffix to use for backup
+						 * files */
 char        bakfile[MAXPATHLEN] = "";
 
 int
@@ -99,8 +101,8 @@ main(int argc, char **argv)
 
     int         last_else = 0;	/* true iff last keyword was an else */
     const char *profile_name = NULL;
+    const char *envval = NULL;
 
-
     /*-----------------------------------------------*\
     |		      INITIALIZATION		      |
     \*-----------------------------------------------*/
@@ -160,6 +162,10 @@ main(int argc, char **argv)
     output = NULL;
     tabs_to_var = 0;
 
+    envval = getenv("SIMPLE_BACKUP_SUFFIX");
+    if (envval)
+        simple_backup_suffix = envval;
+
     /*--------------------------------------------------*\
     |   		COMMAND LINE SCAN		 |
     \*--------------------------------------------------*/
@@ -1234,7 +1240,7 @@ bakcopy(void)
 	p--;
     if (*p == '/')
 	p++;
-    sprintf(bakfile, "%s.BAK", p);
+    sprintf(bakfile, "%s%s", p, simple_backup_suffix);
 
     /* copy in_name to backup file */
     bakchn = creat(bakfile, 0600);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708071801.v77I1SIG020914>