Keeping Qshell sessions alive

Not a lot of people realise this, but the IBM i has a POSIX compliant shell environment, known as Qshell. It’s relatively basic (compared to both BASH and the native i command line) but it can be quite handy when I need (for example) to grep a source file.

One thing that has always annoyed me about Qshell, however, is that it doesn’t retain any history between sessions. Given that my workflow will involve starting at the i command line, performing a task in Qshell, and then returning to the command line, the lack of a history lead either to unnecessary typing or copying and pasting commands into and out of a text editor.

Today I noticed that the F12 key can be used to disconnect a Qshell session without actually ending it. And when I next enter the QSH command, I find myself back in the same session with my history intact.

This isn’t going to help with finding commands I typed yesterday, but it will allow me to avoid unnecessary retyping within the same day.

Footnote

Why use grep to search a source file rather than the more usual FNDSTRPDM command?

Incompetent contractors is the short answer. Incompetent contractors who introduced an unknown number of divide by zero errors is the slightly longer answer.

In RPG, the division operator is / and the comment symbol is //. I could use FNDSTRPDM to search for all the slashes and then manually scroll past all the comment lines. Or I could shortcut this process with the following piped grep:

grep -in '/' /qsys.lib/sourcelib.lib/qrpglesrc.file/program.mbr | grep -iv '//'

I’m lazy. I grep.

2 thoughts on “Keeping Qshell sessions alive

  1. This doesn’t seem to work anymore. Looks like the `-r` flag is no lgnoer supported.Also looks like the preferred way of doing it now is by adding to the build.gradle: applicationName = ‘newProjectName’Otherwise you can add to settings.gradle: rootProject.name = ‘newProjectName’

    Like

  2. It took me a bit of time to remember the context of this post. I’m assuming that you are referring to the grep command in which case you are completely correct to say that the QShell implementation of grep doesn’t support the recursive (-r) flag. So the command, as posted, won’t help if you are searching multiple files but, it is useful for finding multiple occurrences of a string in a single file (which, if memory serves correctly, is what I was trying to do.

    When you talk about gradle, are you referring to the Eclipse (Rational Developer for i) plugin? If so, that probably is a better approach, as long as you have RDi installed.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s