1 |
On 06/12/16 23:07, Andrew Lowe wrote: |
2 |
> On 06/12/16 22:43, Alan McKinnon wrote: |
3 |
>> On 12/06/2016 16:33, Nico Verrijdt wrote: |
4 |
>>> Hi Andrew, |
5 |
>>> |
6 |
>>> 2016-06-12 16:26 GMT+02:00 Andrew Lowe <agl@×××××××.au |
7 |
>>> <mailto:agl@×××××××.au>>: |
8 |
>>> |
9 |
>>> Hi all, |
10 |
>>> A bit off topic here, but there are plenty of people who |
11 |
>>> seem to know their shells back to front so here goes. |
12 |
>>> |
13 |
>>> I have set up a Win32 based development environment, |
14 |
>>> bash/cc/ls/etc/etc, for 1st year Engineering students who have to |
15 |
>>> learn C on a command line. It's fine for me to remember to put the & |
16 |
>>> at the end of the command when I fire up the editor but for them, |
17 |
>>> it's major angst. |
18 |
>>> |
19 |
>>> The first thing that comes to mind is an alias. Just off |
20 |
>>> the top of my head I tried: |
21 |
>>> |
22 |
>>> alias "npp=npp %1 &" |
23 |
>>> |
24 |
>>> Shouldn't this be: alias npp="npp %1 &" ? |
25 |
>>> |
26 |
>>> |
27 |
>>> npp being the editor, but that didn't work. Is an alias the |
28 |
>>> best/easiest way to do this and if so, what would the syntax be, or |
29 |
>>> is there a better way? |
30 |
>>> |
31 |
>>> Any thoughts, greatly appreciated, |
32 |
>>> |
33 |
>>> Andrew |
34 |
>>> |
35 |
>>> |
36 |
>>> Hope this helps, |
37 |
>>> Nico |
38 |
>> |
39 |
>> |
40 |
>> Or just tell them to remember to add the & at the end. |
41 |
>> With an alias what will they do when they don't want it? |
42 |
>> |
43 |
>> Or look at it this way: |
44 |
>> |
45 |
>> It's syntax, it's important. C is probably more syntax-critical than any |
46 |
>> other language around (binds to the right, anyone?) so what's the |
47 |
>> problem with requiring correct syntax on the command line as well? |
48 |
>> |
49 |
>> Obligatory disclaimer: I've recently had a bellyache full of dumb people |
50 |
>> who insist I put code when a human (themselves) belongs... |
51 |
>> |
52 |
> Yes, I agree BUT, this is a "half subject" in a common first year of |
53 |
> an Engineering degree. These are people who will become |
54 |
> Civil/Mechanical/Electrical/Chemical Engineers and they have no desire |
55 |
> to learn programming. To put it bluntly, all they are interested in is |
56 |
> their car, getting drunk and trying to get a root - the order may vary, |
57 |
> but that is the top three priorities. Anything else is just too much to |
58 |
> think about. |
59 |
> |
60 |
> In reality, I'm doing this to make my life easier. As much as I tell |
61 |
> them to do something, write up documents that tell them what to do and |
62 |
> reiterate what they have to do, I still get the question "It's broken, |
63 |
> it won't do as I want...." |
64 |
> |
65 |
> Andrew |
66 |
> |
67 |
> p.s. Nico's point was a typo on my part in the email. |
68 |
> |
69 |
|
70 |
Simple answer to this which a single google search found. You CAN'T |
71 |
pass parameters to an alias under Bash. You need to do a function. A |
72 |
simple function of: |
73 |
|
74 |
npp() |
75 |
{ |
76 |
npp $1 & |
77 |
} |
78 |
|
79 |
was all I needed. |
80 |
|
81 |
Andrew |