Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix confusing example in paste(1) #163

Closed
wants to merge 1 commit into from
Closed

Conversation

jocki84
Copy link
Contributor

@jocki84 jocki84 commented Jul 12, 2018

Paste's man page contains an example for a reimplementation of nl(1). This example uses the command line

sed = myfile | paste -s -d '\t\n' - -

in order to concatenate consecutive lines with an intervening tab.

However, the way the example uses the switches -s and -d and two - input files is redundant. There are in fact two equivalent but simpler ways to achieve the desired result:

sed = myfile | paste -s -d '\t\n' -

uses the same style as the previous example, while

sed = myfile | paste - -

is arguably even simpler and illustrates the final sentence of the DESCRIPTION.

I therefore suggest to change the example to the latter style.

Paste's man page contains an example for a reimplementation of nl(1). This example uses the command line
    sed = myfile | paste -s -d '\t\n' - -
in order to concatenate consecutive lines with an intervening tab.

However, the way the example uses the switches -s and -d and two `dash` input files is redundant. There are in fact two equivalent but simpler ways to achieve the desired result:
    sed = myfile | paste -s -d '\t\n' -
uses the same style as the previous example, while
    sed = myfile | paste - -
is arguably even simpler and illustrates the final sentence of the DESCRIPTION.

I therefore suggest to change the example to the latter style.
@ngie-eign
Copy link
Contributor

ngie-eign commented Dec 18, 2018

Hmmm... it's not exactly equivalent from what I can tell, but I guess it's close..?

$ cat myfile 
a=b
c: d
'e'^1
$ sed = myfile | paste - -                                                                                                                                            
1       a=b
2       c: d
3       'e'^1
$ nl myfile 
     1  a=b
     2  c: d
     3  'e'^1

I don't see why this shouldn't be merged (.Dd will just need to be bumped for the change).

CC: @allanjude

@jocki84
Copy link
Contributor Author

jocki84 commented Dec 18, 2018

@ngie-eign yes, it's only nl(1) »in spirit« – the text does mention that the result is »similar« to the output of nl(1).

I think it would be a good idea to use paste - - in this example to demonstrate a technique that only works with stdin. For physical files, paste -s -d '\t\n' has to be used to achieve the effect, which is what the previous example is about.

@bsdimp
Copy link
Member

bsdimp commented May 31, 2021

Closing... pushed into head as 8790fe3. The example is simpler and easier to follow. It doesn't have to be perfectly the same as nl(1).

@bsdimp bsdimp closed this May 31, 2021
freebsd-git pushed a commit that referenced this pull request May 31, 2021
Paste's man page contains an example for a reimplementation of
nl(1). This example uses the command line
    sed = myfile | paste -s -d '\t\n' - -
in order to concatenate consecutive lines with an intervening tab.

However, the way the example uses the switches -s and -d and two `dash`
input files is redundant. There are in fact two equivalent but simpler
ways to achieve the desired result:
    sed = myfile | paste -s -d '\t\n' -
uses the same style as the previous example, while
    sed = myfile | paste - -
is arguably even simpler and illustrates the final sentence of the
DESCRIPTION.

Reviewed by:		imp@
Pull Request:		#163
bsdjhb pushed a commit to bsdjhb/cheribsd that referenced this pull request Dec 9, 2021
Paste's man page contains an example for a reimplementation of
nl(1). This example uses the command line
    sed = myfile | paste -s -d '\t\n' - -
in order to concatenate consecutive lines with an intervening tab.

However, the way the example uses the switches -s and -d and two `dash`
input files is redundant. There are in fact two equivalent but simpler
ways to achieve the desired result:
    sed = myfile | paste -s -d '\t\n' -
uses the same style as the previous example, while
    sed = myfile | paste - -
is arguably even simpler and illustrates the final sentence of the
DESCRIPTION.

Reviewed by:		imp@
Pull Request:		freebsd/freebsd-src#163
@emaste emaste added the merged label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants