-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[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
Conversation
Converted to Draft (temporarily) -- there's a little more that can be done here. |
Ready for review (option |
doc/command_line/field_processing.md
Outdated
|
||
Note that `gets` reads the next line and sets global variable `$_` | ||
to the last read line; | ||
note also that character `'$'` must be escaped as `'\$'`: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed (7 places).
doc/command_line/field_processing.md
Outdated
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"] | ||
``` |
There was a problem hiding this comment.
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"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note added.
There was a problem hiding this comment.
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.
Changed heading levels (downward), with a view to possible eventual file inclusion. |
@peterzhu2118, is this ready to merge, do you think? |
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 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?) |
@peterzhu2118, ready, I think. |
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 ofdoc/
) because I'm planning more files documenting more CLI options. These may eventually be gathered into an inclusivedoc/command_line_options.md
.