Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7a32330

Browse files
committedJul 22, 2022
Make cat work correctly depending on env var
* If the env var UBERFTP_CAT_CORRECT is present, omit the odd UNIX newline that is printed out for non-empty files * Fixes #22
1 parent 59d71f4 commit 7a32330

File tree

6 files changed

+45
-11
lines changed

6 files changed

+45
-11
lines changed
 

‎ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ Version 2.9.1 (Pre Release)
22
- The fix for recursive listings was incomplete and created a regression
33
preventing recursive file transfer operations to succeed. This is
44
fixed now.
5+
- If the environment variable UBERFTP_CAT_CORRECT is present, this
6+
version omits the odd newline that is printed out by the cat
7+
functionality of previous versions of UberFTP. If not, the old
8+
behaviour is used for compatibility reasons.
59

610
Version 2.9 09/02/22
711
- Build fixed for 32bit

‎NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Version number scheme changed to semver (see semver.org)
44
Bugfixes:
55
- get -r and mget didn't work correctly in version 2.9 compared to version 2.8.
66
This is fixed in this version.
7+
- cat did put out an odd newline after the file contents in previous versions.
8+
This is prevented if the environment variable UBERFTP_CAT_CORRECT is present.
79

810
Version 2.9
911
-----------

‎cmds.c

+12-5
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@ static cmd_t gcmdlist [] = {
278278
"bye\n", NULL},
279279

280280
{ _c_cat, "cat", C_A_RCH_1|C_A_STRINGS,
281-
"Print the contents of the remote file(s) to stdout.\n",
281+
"Print the contents of the remote file(s) to stdout.\n"
282+
"See CAT BEHAVIOUR in uberftp(1) for details about the behaviour of this\n"
283+
"functionality.\n",
282284
"cat file1 [file2 ... filen]\n", NULL},
283285

284286
{ _c_chdir, "cd", C_A_RCH_1|C_A_OSTRING,
@@ -396,7 +398,9 @@ static cmd_t gcmdlist [] = {
396398
"seconds number of seconds between NOOPs. Disabled if zero.\n"},
397399

398400
{ _c_cat, "lcat", C_A_LCH_1|C_A_STRINGS,
399-
"Print the contents of the local file(s) to stdout.\n",
401+
"Print the contents of the local file(s) to stdout.\n"
402+
"See CAT BEHAVIOUR in uberftp(1) for details about the behaviour of this\n"
403+
"functionality.\n",
400404
"lcat file1 [file2 ... filen]\n", NULL},
401405

402406
{ _c_chdir, "lcd", C_A_LCH_1|C_A_OSTRING,
@@ -1465,8 +1469,11 @@ _c_cat(ch_t * ch, char ** files)
14651469
FREE(buf);
14661470
}
14671471

1468-
if (nl)
1469-
o_printf(DEBUG_ERRS_ONLY, "\n");
1472+
if ( getenv("UBERFTP_CAT_CORRECT") == NULL )
1473+
{
1474+
if (nl)
1475+
o_printf(DEBUG_ERRS_ONLY, "\n");
1476+
}
14701477

14711478
finish:
14721479
ecl = l_close(ch->lh);
@@ -3807,7 +3814,7 @@ main()
38073814
char * tok = NULL;
38083815
int i = 0;
38093816

3810-
printf(".TH UBERFTP 1C \"16 May 2008\"\n");
3817+
printf(".TH UBERFTP 1 \"22 Jul 2022\"\n");
38113818
printf(".SH COMMANDS\n");
38123819

38133820
for (i = 0; gcmdlist[i].name != NULL; i++)

‎main.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,9 @@ printf(
385385
#ifndef MSSFTP
386386
"The supported \"-cmds\" are:\n"
387387
"\t-cat <url>\n"
388-
"\t Print to stdout the contents of the remote file.\n"
388+
"\t Print to stdout the contents of the remote file. See CAT\n"
389+
"\t BEHAVIOUR in uberftp(1) for details about the behaviour of\n"
390+
"\t this functionality.\n"
389391
"\t-chgrp [-r] group <url>\n"
390392
"\t Set the group ownership on the remote object(s).\n"
391393
"\t-chmod [-r] perms <url>\n"

‎packaging/fedora/uberftp.spec

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ make install DESTDIR=%{buildroot}
3636

3737
%changelog
3838

39-
* Thu Jul 14 2022 Frank Scheiner <scheiner@hlrs.de> - 2.9.1-1
39+
* Thu Jul 22 2022 Frank Scheiner <scheiner@hlrs.de> - 2.9.1-1
4040
- New upstream version 2.9.1
4141
- changed version scheme to semver (see semver.org)
4242
- fixed recursive listings
43+
- correct cat behaviour depending on environment var
4344

4445
* Tue Jan 18 2022 Frank Scheiner <scheiner@hlrs.de> - 2.9-1
4546
- New upstream version 2.9

‎uberftp.1

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.\" @(#)uberftp.1c 1.34 90/02/15 SMI; from UCB 4.3
2-
.TH UBERFTP 1C "12 Nov 2020"
2+
.TH UBERFTP 1 "22 Jul 2022"
33
.SH NAME
44
uberftp \- GridFTP-enabled client
55
.SH SYNOPSIS
@@ -183,7 +183,8 @@ Print version information about all used globus modules and exit.
183183
.SH Supported \-cmds
184184
.TP
185185
.B \-cat \fIurl\fR
186-
Print to stdout the contents of the remote file.
186+
Print to stdout the contents of the remote file. See \fBCAT BEHAVIOUR\fR below for
187+
details about the behaviour of this functionality.
187188
.TP
188189
.B \-chgrp [\fI-r\fR] \fIgroup\fR \fIurl\fR
189190
Set the group ownership of the remote object(s).
@@ -290,7 +291,8 @@ Prints information regarding bug reporting and feature requests.
290291
Close all control and data connections and exit.
291292
.TP
292293
.B cat \fIfile1\fR [\fIfile2\fR ... \fIfilen\fR]
293-
Print the contents of the remote file(s) to stdout.
294+
Print the contents of the remote file(s) to stdout. See \fBCAT BEHAVIOUR\fR below for
295+
details about the behaviour of this functionality.
294296
.TP
295297
.B cdup
296298
Change the remote working directory up one level.
@@ -400,7 +402,8 @@ displayed. This feature is disabled by default.
400402
seconds number of seconds between NOOPs. Disabled if zero.
401403
.TP
402404
.B lcat \fIfile1\fR [\fIfile2\fR ... \fIfilen\fR]
403-
Print the contents of the local file(s) to stdout.
405+
Print the contents of the local file(s) to stdout. See \fBCAT BEHAVIOUR\fR below for
406+
details about the behaviour of this functionality.
404407
.TP
405408
.B lcd [\fIdir\fR]
406409
Change the local working directory to \fIdir\fR. If \fIdir\fR is not given,
@@ -796,6 +799,21 @@ Setting the ephemeral port range to an unusable range will cause UberFTP connect
796799
to fail. For instance, setting a port range from 10 to 100 with a non root process will
797800
fail on most operating systems.
798801

802+
.SH CAT BEHAVIOUR
803+
.LP
804+
UberFTP 2.9.1 comes with an additional environment variable:
805+
806+
UBERFTP_CAT_CORRECT
807+
808+
If this environment variable is present UberFTP omits the odd newline that is
809+
otherwise printed out in addition to the file contents by the \fBcat\fR
810+
functionality of previous versions of UberFTP for non-empty files. If it is not
811+
present, the old behaviour is used for compatibility reasons. The content of
812+
this environment variable is not evaluated, just its presence in your
813+
environment. Also see:
814+
815+
https://github.com/gridcf/UberFTP/issues/22
816+
799817
.SH EXIT VALUES
800818
.LP
801819
UberFTP will exit with a value of 0 if no errors occurred during the session,

0 commit comments

Comments
 (0)
Please sign in to comment.