Skip to content

[DOC] Doc for field processing #10008

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

Merged
merged 6 commits into from
Feb 21, 2024
Merged

[DOC] Doc for field processing #10008

merged 6 commits into from
Feb 21, 2024

Conversation

BurdetteLamar
Copy link
Member

Documents command-line options -n, -p, -a, and -F, each affecting field processing.

I've put the new file into directory doc/command_line/ (instead of doc/) because I'm planning more files documenting more CLI options. These may eventually be gathered into an inclusive doc/command_line_options.md.

@BurdetteLamar BurdetteLamar added the Documentation Improvements to documentation. label Feb 17, 2024
@BurdetteLamar BurdetteLamar marked this pull request as draft February 17, 2024 16:41
@BurdetteLamar
Copy link
Member Author

Converted to Draft (temporarily) -- there's a little more that can be done here.

@BurdetteLamar BurdetteLamar marked this pull request as ready for review February 17, 2024 17:22
@BurdetteLamar
Copy link
Member Author

Ready for review (option -l added).


Note that `gets` reads the next line and sets global variable `$_`
to the last read line;
note also that character `'$'` must be escaped as `'\$'`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That escape is needed when enclosed in double quotes or no quotes.
Is it for the sake of Windows, not to use single quotes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed (7 places).

Comment on lines 85 to 94
Option `-F`, when given with option `-a`,
specifies that its argument is to be the input field separator to be used for splitting:

```sh
$ ruby -an -Fs -e "p \$F" desiderata.txt
["Go placidly amid the noi", "e and the ha", "te,\n"]
["and remember what peace there may be in ", "ilence.\n"]
["A", " far a", " po", "", "ible, without ", "urrender,\n"]
["be on good term", " with all per", "on", ".\n"]
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth mentioning that the arguments are compiled as regular expressions.

$ ruby -an -F'[.,]\s*' -e 'p $F' desiderata.txt
["Go placidly amid the noise and the haste"]
["and remember what peace there may be in silence"]
["As far as possible", "without surrender"]
["be on good terms with all persons"]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note added.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added @nobu example with remark.

@BurdetteLamar BurdetteLamar requested a review from nobu February 18, 2024 16:27
@BurdetteLamar
Copy link
Member Author

Changed heading levels (downward), with a view to possible eventual file inclusion.

@BurdetteLamar
Copy link
Member Author

@peterzhu2118, is this ready to merge, do you think?

@peterzhu2118
Copy link
Member

Can you also clarify how this doc will be used? For example, where will it be linked from. Right now, it's not very easy to find by the average reader.

@BurdetteLamar
Copy link
Member Author

Can you also clarify how this doc will be used? For example, where will it be linked from. Right now, it's not very easy to find by the average reader.

I'm working toward docs in doc/command_line, that will cover all the command-line options, likely included into doc/command_line/options.md.

I'd like then to add a URL address to the help text, referring the reader to these robust write-ups. (Too bad it can't be a link -- or can it?)

@BurdetteLamar
Copy link
Member Author

@peterzhu2118, ready, I think.

@peterzhu2118 peterzhu2118 merged commit fce7804 into ruby:master Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements to documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants