getting carriage return character in vacuumo

Started by Muhammad Usamaalmost 15 years ago4 messages
#1Muhammad Usama
m.usama@gmail.com
1 attachment(s)

Hi,

While using the vacuumlo utility I encountered a redundant carriage
return(\r') character in the output. It is required in any scenario? If not,
please find attached a tiny patch which will get rid of that extra '\r'
character.

Regards,
Usama

Attachments:

carriage_return_in_vacuumlo.patchapplication/octet-stream; name=carriage_return_in_vacuumlo.patchDownload
diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c
index 2ed1cbe..3a5ff78 100644
--- a/contrib/vacuumlo/vacuumlo.c
+++ b/contrib/vacuumlo/vacuumlo.c
@@ -270,7 +270,7 @@ vacuumlo(char *database, struct _param * param)
 
 		if (param->verbose)
 		{
-			fprintf(stdout, "\rRemoving lo %6u   ", lo);
+			fprintf(stdout, "Removing lo %6u   ", lo);
 			fflush(stdout);
 		}
 
@@ -298,7 +298,7 @@ vacuumlo(char *database, struct _param * param)
 	PQfinish(conn);
 
 	if (param->verbose)
-		fprintf(stdout, "\r%s %d large objects from %s.\n",
+		fprintf(stdout, "%s %d large objects from %s.\n",
 		   (param->dry_run ? "Would remove" : "Removed"), deleted, database);
 
 	return 0;
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Muhammad Usama (#1)
Re: getting carriage return character in vacuumo

Muhammad Usama <m.usama@gmail.com> writes:

While using the vacuumlo utility I encountered a redundant carriage
return(\r') character in the output. It is required in any scenario? If not,
please find attached a tiny patch which will get rid of that extra '\r'
character.

I think the idea there is to overwrite successive progress messages
on the same line. It's maybe not going to work in all environments,
though, so perhaps we should reconsider that bit of cuteness.

regards, tom lane

#3Martijn van Oosterhout
kleptog@svana.org
In reply to: Tom Lane (#2)
Re: getting carriage return character in vacuumo

On Fri, Apr 08, 2011 at 02:10:56PM -0400, Tom Lane wrote:

Muhammad Usama <m.usama@gmail.com> writes:

While using the vacuumlo utility I encountered a redundant carriage
return(\r') character in the output. It is required in any scenario? If not,
please find attached a tiny patch which will get rid of that extra '\r'
character.

I think the idea there is to overwrite successive progress messages
on the same line. It's maybe not going to work in all environments,
though, so perhaps we should reconsider that bit of cuteness.

One could hinge it on batch or non-batch mode, the default being
determined by whether it's running in a terminal or not.

Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

Patriotism is when love of your own people comes first; nationalism,
when hate for people other than your own comes first.
- Charles de Gaulle

#4Bruce Momjian
bruce@momjian.us
In reply to: Martijn van Oosterhout (#3)
Re: getting carriage return character in vacuumo

Martijn van Oosterhout wrote:
-- Start of PGP signed section.

On Fri, Apr 08, 2011 at 02:10:56PM -0400, Tom Lane wrote:

Muhammad Usama <m.usama@gmail.com> writes:

While using the vacuumlo utility I encountered a redundant carriage
return(\r') character in the output. It is required in any scenario? If not,
please find attached a tiny patch which will get rid of that extra '\r'
character.

I think the idea there is to overwrite successive progress messages
on the same line. It's maybe not going to work in all environments,
though, so perhaps we should reconsider that bit of cuteness.

One could hinge it on batch or non-batch mode, the default being
determined by whether it's running in a terminal or not.

pg_upgrade also uses this \r status update trick unconfitionally.
Should we fix these?

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +