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

Don't include ">" in bash scripts #460

Merged
merged 1 commit into from
Nov 26, 2019
Merged

Don't include ">" in bash scripts #460

merged 1 commit into from
Nov 26, 2019

Conversation

hbina
Copy link
Contributor

@hbina hbina commented Oct 7, 2019

This makes copying inconvenient as > ./x.py build -i --stage 1 src/libstd will actually render your x.py file empty...

JohnTitor
JohnTitor previously approved these changes Oct 7, 2019
@spastorino
Copy link
Member

We could use a $ sign but please check out through the whole guide because there are tons of "```bash" pieces and we would need to update them all.

@hbina
Copy link
Contributor Author

hbina commented Oct 7, 2019

We could use a $ sign

I don't quite understand. Even if I replace > it will simply copy the entire text and $ is not a valid bash command...

please check out through the whole guide because there are tons of "```bash" pieces and we would need to update them all.

Okay, I am going to apply the changes to all of them now....

@spastorino
Copy link
Member

spastorino commented Oct 7, 2019

I don't quite understand. Even if I replace > it will simply copy the entire text and $ is not a valid bash command...

Yeah, I just meant that would be a bit more obvious that you don't need to copy if you have $ it's more clear that you're on a shell. IMO the best solution is to have the $ sign but once you try to highlight all the text the dollar sign is not highlighted.

@hbina
Copy link
Contributor Author

hbina commented Oct 7, 2019

But the "copy to clipboard* button will copy the entire text, including the $...I guess there are no good solution to this?

@shepmaster
Copy link
Member

shepmaster commented Oct 7, 2019

```bash pieces

FWIW, it's generally incorrect to use ```bash for code blocks that represent user interaction, especially multiple interactions or with output. That should be reserved for actual bash shell script. As a concrete example, $ denotes a variable usage in bash, # is a comment, and > is a redirect, yet all of those are used as prompt indicators.

@spastorino
Copy link
Member

Sorry because I may be having hard time to express my idea :). I feel like in these blocks we should have just the thing that needs to be run, in this case ./x.py build -i --stage 1 src/libstd but I guess we may want to apply some css style to this and maybe prepend a prompt indicator.

Also what @shepmaster says is true. I'm not sure what would be the best solution /cc @mark-i-m

@tshepang
Copy link
Member

tshepang commented Oct 7, 2019

I myself use prompt characters only when including command output (for easy visual separation), otherwise I do not add it for copy-paste convenience.

@mark-i-m
Copy link
Member

@tshepang That seems like a reasonable rule to me

@spastorino
Copy link
Member

So in order to make progress with this my suggestion is ...

  1. Let's get rid of all of the prompt symbols in the guide
  2. Open an issue to handle script blocks with css/js styling. I think we should add a prompt but as part of presentation and once you select text that part is not selected.

@mark-i-m
Copy link
Member

@spastorino I don't know how to do #2 in mdbook, but it sounds good to me.

@mark-i-m mark-i-m mentioned this pull request Nov 14, 2019
@mark-i-m
Copy link
Member

@hbina Thanks for the PR! Are you still interested in working on this? If so, could you remove all the > thoughout the book and rebase on top of master?

@hbina
Copy link
Contributor Author

hbina commented Nov 14, 2019

Uh oh, I guess I better start finish reading the book. Sure, I can work on them. I only know how to do the first one tho, I am not entirely knowledgeable in CSS styling stuff

@spastorino
Copy link
Member

@hbina going over the first one is good enough for now :)

@mark-i-m
Copy link
Member

I think we can leave CSS for a follow-up pr. For now, perhaps we can start by just removing the characters?

@hbina
Copy link
Contributor Author

hbina commented Nov 14, 2019

My latest commit removes a bunch of > from code blocks that are meant to be executed. I left, and, sometimes added, $ and / where necessary. Plus, those code are not meant to be copied anyway.

Copy link
Member

@spastorino spastorino left a comment

Choose a reason for hiding this comment

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

I see you did you added some of the $ but seems opposed what we are trying to do.
To be honest unsure how to best fix this without doing the css styling idea.

@mark-i-m do you have any other idea?.

@@ -260,7 +260,7 @@ usually also want to give `--tree-min-percent` or
`--tree-max-depth`. The result looks like this:

```bash
> perf focus '{do_mir_borrowck}' --tree-callees --tree-min-percent 3
$ perf focus '{do_mir_borrowck}' --tree-callees --tree-min-percent 3
Copy link
Member

Choose a reason for hiding this comment

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

Same

@@ -232,7 +232,7 @@ Perhaps we'd like to know how much time MIR borrowck spends in the
trait checker. We can ask this using a more complex regex:

```bash
> perf focus '{do_mir_borrowck}..{^rustc::traits}'
$ perf focus '{do_mir_borrowck}..{^rustc::traits}'
Copy link
Member

Choose a reason for hiding this comment

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

Same

@@ -191,7 +191,7 @@ function of the MIR borrowck is called `do_mir_borrowck`, so we can do
this command:

```bash
> perf focus '{do_mir_borrowck}'
$ perf focus '{do_mir_borrowck}'
Copy link
Member

Choose a reason for hiding this comment

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

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought the text below this are meant to show an example of what will be displayed? In this case, the "copy to clipboard" button is meaningless regardless. So thats why I thought adding $ is okay to convey what would appear in a console. My original PR was really about "texts that are meant to be executed, should be executable from what is copied to the clipboard".

@@ -385,7 +385,7 @@ should see a version number ending in `-dev`, indicating a build from
your local environment:

```bash
> rustc +stage1 -vV
$ rustc +stage1 -vV
Copy link
Member

Choose a reason for hiding this comment

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

Hmm I see why you added $ there but I'm not sure what to think about this.
cc @mark-i-m

@@ -311,7 +311,7 @@ could get our percentages relative to the borrowck itself
like so:

```bash
> perf focus '{do_mir_borrowck}' --tree-callees --relative --tree-max-depth 1 --tree-min-percent 5
$ perf focus '{do_mir_borrowck}' --tree-callees --relative --tree-max-depth 1 --tree-min-percent 5
Copy link
Member

Choose a reason for hiding this comment

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

Same

@mark-i-m
Copy link
Member

@spastorino Personally, I think this is ok. One would not copy/paste the whole block anyway in these cases, and I think having the prompt will improve the syntax highlighting of mdbook...

IMHO, we should just merge...

spastorino
spastorino previously approved these changes Nov 18, 2019
@spastorino
Copy link
Member

@hbina I've just approved the changes and I was going to merge them but there are some conflicts now, do you mind rebasing?. Sorry for not merging it before and hitting this new conflicts.

@mark-i-m
Copy link
Member

Umm... looks like rebase went wrong?

@hbina
Copy link
Contributor Author

hbina commented Nov 21, 2019

Oh...that's really bad...
I did git rebase --onto master patch-1 but I guess that's wrong?

Specifically, `> $1` causes it to write into the file $1 if it exist
And `> ./x.py` is particularly bad because it overwrite the script with
empty spaces...
@hbina
Copy link
Contributor Author

hbina commented Nov 21, 2019

Should be okay now?

@mark-i-m
Copy link
Member

Yeah, I'm not really sure why that happens. Occasionally I do that too.

For whatever reason, git checkout your-branch; git rebase master seems to fix it. I think that is equivalent to what you ran but for some reason running it again seems to fix things...

@mark-i-m
Copy link
Member

Yep, that looks much better :)

Copy link
Member

@mark-i-m mark-i-m left a comment

Choose a reason for hiding this comment

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

Thanks! This looks good to me. We can do more discussion on zulip or in an issue I think.

@mark-i-m mark-i-m merged commit d373bca into rust-lang:master Nov 26, 2019
@hbina hbina deleted the patch-1 branch September 20, 2020 05:55
@ghost
Copy link

ghost commented Sep 20, 2020

This code blocks should not be marked as bash, there is nothing bash specific in them. They should be marked as sh.

@shepmaster
Copy link
Member

They should be marked as sh.

I disagree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants