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

Implement way to check use of history commands in shell courses #40

Open
filipsch opened this issue May 24, 2018 · 4 comments
Open

Implement way to check use of history commands in shell courses #40

filipsch opened this issue May 24, 2018 · 4 comments

Comments

@filipsch
Copy link
Contributor

@gvwilson commented on Thu May 17 2018

From datacamp-content/courses-introduction-to-shell#129: if the user types !cat to repeat the last cat command, the user input we see in the SCT is cat filename (or whatever they last typed), not !cat, because history expansion is done before we get the text to check.

@machow
Copy link
Contributor

machow commented May 25, 2018

@filipsch this is not ideal, but history expansion is not an issue for the NormalExercise. It will see !cat

(context here: https://github.com/datacamp/shellbackend#kernel-limitations)

@gvwilson
Copy link

Thanks @machow - why does the expansion show up in NormalExercise but not in ConsoleExercise ??

@machow
Copy link
Contributor

machow commented May 25, 2018

@gvwilson the NormalExercise is similar to writing bash code in a file. The backend receives the raw code in that file and decides how to run it / passes it to the SCTs. In a ConsoleExercise, the student is delivering STDIN to a terminal, which could be doing anything to that input. Seeing

> !cat

when a student types !cat is just a side effect of how the shell is running at that moment in time (for example, if they had vim open and typed !cat the result would be very different). There is no "student code". All we know is that they typed a stream of characters (including delete, etc..), and some ascii canvas thing has drawn a bunch of characters.

Through bash hooks and black magic, we can get back what code they are running when they run it, and give it to the SCTs. However, bash doesn't see !cat. Very early on when bash is interpreting !cat it expands it. This happens before bash even chops commands into separate "words".

(the issue referenced in the README I linked above points to the relevant bash docs)

@filipsch
Copy link
Contributor Author

I think this issue is not worth looking into. It's going to be used in 5 to 10 exercises at most in the coming year (currently only 1).

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

No branches or pull requests

3 participants