help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] bash to csh converter?


From: Mun
Subject: Re: [Help-bash] bash to csh converter?
Date: Mon, 21 Mar 2016 10:01:32 -0700
User-agent: Mutt/1.5.21 (2010-09-15)

Hi Steven, Bob,

Sorry for the delay in my response.
Please see my comments below.

On Sat, Mar 19, 2016 at 09:54 AM PDT, Steven Ford wrote:
SF>    Mun,
SF>    I am also curious about the details here.
SF>    What kind of issues were you running into using the bash scripts from 
csh?

Mostly trivial; but to be honest, I haven't peeled the onion back too
far yet.  For example, the first thing I hit was that when I run the
script under csh, I get the following error:

File name too long.
if: Expression Syntax.

I have no issues when run under bash.  I'm sure this is something
trivial, I just haven't looked into it yet.  I've also noticed that
there are subtle differences when the usage statement is printed out
(under csh the "\n" is visible).  Again, trivial; but just had me
wondering if it would be better to convert the script to csh.

SF>    Are they meant to create aliases or set environment variables?

Yes.  And because environment variables are being set (requiring some
scripts to be sourced) I didn't think that would work when the script
was run under csh (although, I must admit I haven't tried it yet).

SF>    How many lines of bash code do you have that rewriting them is not 
practical?

It's not necessarily impractical at this point; but my main reason for
posting something to this list was just to see if an automated solution
was available.  If not, then I'll decide the next best course of action.

SF>    If the bash scripts have functions that they need to use, you could make 
those functions
SF>    accessible as individual bash scripts or modify your bash scripts to 
call a function passed as
SF>    an argument.
SF>    Something like this:
SF>    #!/bin/sh
SF>    function foo {
SF>      echo foo
SF>    }
SF>    function bar {
SF>      echo bar
SF>    }
SF>    $@
SF>    Would allow you to invoke the bash functions like ./script.sh foo with 
minimal modification to
SF>    the bash script by adding $@ to the bottom. That is if the functions are 
what you need.

Nice tip; thanks.

In summary, I very much appreciate the feedback I've received here.  But
my intention is not to ask for help solving the problems of why the bash
scripts don't run correctly under csh (well, not yet anyway ;) but just
to query if a conversion script/program exists.  If not, then I will
need to decide on the next best resolution so that bash and csh users
can co-exist with minimal re-work.

SF>    Hope this is helpful.

Most certainly!

Best regards,

-- 
Mun

SF>    Regards,
SF>    Steve
SF>    On Sat, Mar 19, 2016 at 2:21 AM, Mun <address@hidden> wrote:
SF> 
SF>      Hi Bob,
SF> 
SF>      Thank you for your reply.
SF>      Please see my comments below.
SF> 
SF>      On Fri, Mar 18, 2016 at 05:16 PM PDT, Bob Proulx wrote:
SF>      BP> Mun wrote:
SF>      BP> > I need to convert some scripts from bash to t/csh and was 
wondering if
SF>      BP> > anyone knew of any good converter script/mjtool?  So far my 
Google'ing has
SF>      BP> > been fruitless.
SF>      BP>
SF>      BP> Your posting prompts me to ask questions.  Since #!/bin/csh 
scripting
SF>      BP> is generally regarded as inferior to #!/bin/sh scripting, a 
proposal
SF>      BP> such as this triggers questions.  Are you sure you want to go that
SF>      BP> direction and not the other way?  Please, please say that it is 
the
SF>      BP> other way around.
SF> 
SF>      Sorry, but I really need to go from Bash to csh.  I write my shell
SF>      scripts in Bash; but many folks at work use a csh env.  At this 
point, I
SF>      am researching a solution for them: one possibility being the 
conversion
SF>      of said scripts to csh.
SF> 
SF>      BP> Note that scripts can always use #!/bin/bash to
SF>      BP> select the interpreter it doesn't make sense to convert those 
scripts
SF>      BP> to #!/bin/csh.
SF> 
SF>      I had already tried that but ran into issue.
SF> 
SF>      BP> I can only assume that you are working in a tcsh prompt and are
SF>      BP> sourcing files and are trying to convert some bash to something 
that
SF>      BP> can be sourced in the csh .login file.  Am I close?
SF> 
SF>      That's pretty close; except I work in the Bash world.  Many of my 
peers
SF>      do not, but they require the functionality of the Bash scripts.
SF> 
SF>      Thanks,
SF>      --
SF>      Mun




reply via email to

[Prev in Thread] Current Thread [Next in Thread]