public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Portable shell code between Cygwin and Linux
@ 2011-07-29 19:15 Sebastien Vauban
  2011-07-29 19:45 ` Larry Hall (Cygwin)
                   ` (2 more replies)
  0 siblings, 3 replies; 32+ messages in thread
From: Sebastien Vauban @ 2011-07-29 19:15 UTC (permalink / raw)
  To: cygwin

Hello,

For every shell code that I write, I'd like it to be portable both to Cygwin
on Windows, and to Ubuntu Linux for example.

It's kinda possible, but am blocked with such a use case:

alias vpnup='exec sudo openvpn --config ~/config/client.vpn --writepid /tmp/openvpn.pid &'

While this worked perfectly under Ubuntu, I've had to make up a customized
version for Windows:

alias vpnupwin='cd c:/home/sva/config; openvpn --config client.vpn --writepid c:/cygwin/tmp/openvpn.pid &'

Here, I cd first to my config file, as I removed full paths from client.vpn
config file:

    ,----
    | ## client.vpn --- client-side OpenVPN config file
    | 
    | # SSL/TLS parms.
    | ca ca.crt
    | cert fni.crt
    | key fni.key
    `----

instead of:

    ,----
    | ## client.vpn --- client-side OpenVPN config file
    | 
    | # SSL/TLS parms.
    | ca /home/sva/config/ca.crt
    | cert /home/sva/config/fni.crt
    | key /home/sva/config/fni.key
    `----

I'm aware of cygpath, but still don't see clearly which are the best trade-off
to be able to write portable shell code -- if possible. Any hint?

Best regards,
  Seb

-- 
Sebastien Vauban


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-07-29 19:15 Portable shell code between Cygwin and Linux Sebastien Vauban
@ 2011-07-29 19:45 ` Larry Hall (Cygwin)
  2011-08-01  6:40   ` Sebastien Vauban
  2011-07-29 19:47 ` Eliot Moss
  2011-07-29 20:17 ` Corinna Vinschen
  2 siblings, 1 reply; 32+ messages in thread
From: Larry Hall (Cygwin) @ 2011-07-29 19:45 UTC (permalink / raw)
  To: cygwin

On 7/29/2011 9:42 AM, Sebastien Vauban wrote:

<snip>

> Here, I cd first to my config file, as I removed full paths from client.vpn
> config file:

<snip>

> I'm aware of cygpath, but still don't see clearly which are the best trade-off
> to be able to write portable shell code -- if possible. Any hint?

Sounds to me like you're using a Windows version of OpenVPN.  You'd need a
version built for Cygwin to make this transparent.

-- 
Larry

_____________________________________________________________________

A: Yes.
 > Q: Are you sure?
 >> A: Because it reverses the logical flow of conversation.
 >>> Q: Why is top posting annoying in email?

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-07-29 19:15 Portable shell code between Cygwin and Linux Sebastien Vauban
  2011-07-29 19:45 ` Larry Hall (Cygwin)
@ 2011-07-29 19:47 ` Eliot Moss
  2011-08-01  6:45   ` Sebastien Vauban
  2011-07-29 20:17 ` Corinna Vinschen
  2 siblings, 1 reply; 32+ messages in thread
From: Eliot Moss @ 2011-07-29 19:47 UTC (permalink / raw)
  To: cygwin

Another way to be portable is to have per-system files
to set up some environment variables and then uniform
portable files that use them. You can do that same
thing *within* a file by writing conditionals or a
case on the result of uname. It's probably best to
segregate per-system stuff in a well-contained file
or section of a file in this way ...

Regards -- Eliot Moss

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-07-29 19:15 Portable shell code between Cygwin and Linux Sebastien Vauban
  2011-07-29 19:45 ` Larry Hall (Cygwin)
  2011-07-29 19:47 ` Eliot Moss
@ 2011-07-29 20:17 ` Corinna Vinschen
  2011-07-30 12:20   ` Andrey Repin
  2011-08-01  7:00   ` Sebastien Vauban
  2 siblings, 2 replies; 32+ messages in thread
From: Corinna Vinschen @ 2011-07-29 20:17 UTC (permalink / raw)
  To: cygwin

On Jul 29 15:42, Sebastien Vauban wrote:
> Hello,
> 
> For every shell code that I write, I'd like it to be portable both to Cygwin
> on Windows, and to Ubuntu Linux for example.
> 
> It's kinda possible, but am blocked with such a use case:
> 
> alias vpnup='exec sudo openvpn --config ~/config/client.vpn --writepid /tmp/openvpn.pid &'
> 
> While this worked perfectly under Ubuntu, I've had to make up a customized
> version for Windows:
> 
> alias vpnupwin='cd c:/home/sva/config; openvpn --config client.vpn --writepid c:/cygwin/tmp/openvpn.pid &'

Don't use Win32 paths.  Use POSIX paths:

  alias vpnupwin='cd /cygdrive/c/home/sva/config; openvpn --config client.vpn --writepid /cygdrive/c/cygwin/tmp/openvpn.pid &'


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-07-29 20:17 ` Corinna Vinschen
@ 2011-07-30 12:20   ` Andrey Repin
  2011-08-01  6:50     ` Sebastien Vauban
  2011-08-08  1:16     ` Sven Köhler
  2011-08-01  7:00   ` Sebastien Vauban
  1 sibling, 2 replies; 32+ messages in thread
From: Andrey Repin @ 2011-07-30 12:20 UTC (permalink / raw)
  To: Corinna Vinschen

Greetings, Corinna Vinschen!

>> For every shell code that I write, I'd like it to be portable both to Cygwin
>> on Windows, and to Ubuntu Linux for example.
>> 
>> It's kinda possible, but am blocked with such a use case:
>> 
>> alias vpnup='exec sudo openvpn --config ~/config/client.vpn --writepid /tmp/openvpn.pid &'
>> 
>> While this worked perfectly under Ubuntu, I've had to make up a customized
>> version for Windows:
>> 
>> alias vpnupwin='cd c:/home/sva/config; openvpn --config client.vpn --writepid c:/cygwin/tmp/openvpn.pid &'

> Don't use Win32 paths.  Use POSIX paths:

>   alias vpnupwin='cd /cygdrive/c/home/sva/config; openvpn --config client.vpn --writepid /cygdrive/c/cygwin/tmp/openvpn.pid &'

Moreover, the very first line is wrong.

Must be

alias vpnup='exec sudo openvpn --config $HOME/config/client.vpn --writepid /tmp/openvpn.pid &'

that's where his problem began, IMO.


--
WBR,
 Andrey Repin (anrdaemon@freemail.ru) 30.07.2011, <16:11>

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-07-29 19:45 ` Larry Hall (Cygwin)
@ 2011-08-01  6:40   ` Sebastien Vauban
  0 siblings, 0 replies; 32+ messages in thread
From: Sebastien Vauban @ 2011-08-01  6:40 UTC (permalink / raw)
  To: cygwin

Hi Larry,

"Larry Hall Cygwin" wrote:
> On 7/29/2011 9:42 AM, Sebastien Vauban wrote:
>> Here, I cd first to my config file, as I removed full paths from client.vpn
>> config file:
>
> <snip>
>
>> I'm aware of cygpath, but still don't see clearly which are the best
>> trade-off to be able to write portable shell code -- if possible. Any hint?
>
> Sounds to me like you're using a Windows version of OpenVPN. You'd need a
> version built for Cygwin to make this transparent.

Yes, I do use a Win32 binary. I first looked for openvpn in the Cygwin
packages, but did not find any.

I didn't dare yet trying to compile such a low-level application (network
interface) in Cygwin, thinking it would never succeed. But who knows...

Best regards,
  Seb

-- 
Sebastien Vauban


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-07-29 19:47 ` Eliot Moss
@ 2011-08-01  6:45   ` Sebastien Vauban
  0 siblings, 0 replies; 32+ messages in thread
From: Sebastien Vauban @ 2011-08-01  6:45 UTC (permalink / raw)
  To: cygwin

Hi Eliot,

Eliot Moss wrote:
> Another way to be portable is to have per-system files to set up some
> environment variables and then uniform portable files that use them. You can
> do that same thing *within* a file by writing conditionals or a case on the
> result of uname. It's probably best to segregate per-system stuff in a
> well-contained file or section of a file in this way ...

Thanks for your answer. But the whole idea is to write something in a way that
it must not be rewritten for the other system.

Maybe it's just a dream.

Best regards,
  Seb

-- 
Sebastien Vauban


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-07-30 12:20   ` Andrey Repin
@ 2011-08-01  6:50     ` Sebastien Vauban
  2011-08-01  7:28       ` Csaba Raduly
  2011-08-05 16:05       ` Andrey Repin
  2011-08-08  1:16     ` Sven Köhler
  1 sibling, 2 replies; 32+ messages in thread
From: Sebastien Vauban @ 2011-08-01  6:50 UTC (permalink / raw)
  To: cygwin

Hi Andrey,

Andrey Repin wrote:
>>> For every shell code that I write, I'd like it to be portable both to
>>> Cygwin on Windows, and to Ubuntu Linux for example.
>>> 
>>> It's kinda possible, but am blocked with such a use case:
>>> 
>>> alias vpnup='exec sudo openvpn --config ~/config/client.vpn --writepid /tmp/openvpn.pid &'
>>> 
>>> While this worked perfectly under Ubuntu, I've had to make up a customized
>>> version for Windows:
>>> 
>>> alias vpnupwin='cd c:/home/sva/config; openvpn --config client.vpn --writepid c:/cygwin/tmp/openvpn.pid &'
>
>> Don't use Win32 paths.  Use POSIX paths:
>
>>   alias vpnupwin='cd /cygdrive/c/home/sva/config; openvpn --config client.vpn --writepid /cygdrive/c/cygwin/tmp/openvpn.pid &'
>
> Moreover, the very first line is wrong.
>
> Must be
>
> alias vpnup='exec sudo openvpn --config $HOME/config/client.vpn --writepid /tmp/openvpn.pid &'
>
> that's where his problem began, IMO.

That's interesting. I thought this was completely equivalent (~ or $HOME), and
preferred the shorter version.

But you say it's not. Can you comment on this?  Thanks in advance...

Best regards,
  Seb

-- 
Sebastien Vauban


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-07-29 20:17 ` Corinna Vinschen
  2011-07-30 12:20   ` Andrey Repin
@ 2011-08-01  7:00   ` Sebastien Vauban
  2011-08-01  7:44     ` Corinna Vinschen
  2011-08-01  9:21     ` Thorsten Kampe
  1 sibling, 2 replies; 32+ messages in thread
From: Sebastien Vauban @ 2011-08-01  7:00 UTC (permalink / raw)
  To: cygwin

Hi Corinna,

Corinna Vinschen wrote:
>> alias vpnup='exec sudo openvpn --config ~/config/client.vpn --writepid /tmp/openvpn.pid &'
>> 
>> While this worked perfectly under Ubuntu, I've had to make up a customized
>> version for Windows:
>> 
>> alias vpnupwin='cd c:/home/sva/config; openvpn --config client.vpn --writepid c:/cygwin/tmp/openvpn.pid &'
>
> Don't use Win32 paths.  Use POSIX paths:
>
>   alias vpnupwin='cd /cygdrive/c/home/sva/config; openvpn --config client.vpn --writepid /cygdrive/c/cygwin/tmp/openvpn.pid &'

But, if I write it like that, this never will work under Ubuntu, does it?  Or
is it possible with some "mount" magic to void the prefix "/cydgrive/c"?

My goal is to have just 1 alias that would work both under Win32 (Cygwin) and
Ubuntu, having the files located in the same place (relative to my home dir).

I also tried you suggestion for another command, which was:

    perl C:/home/sva/src/csv2ledger/CSV2Ledger.pl -f $FileMatches -i $tmpfile.clean

This works fine under Cygwin right now.

Rewritten with POSIX paths:

    perl /cygdrive/c/home/sva/src/csv2ledger/CSV2Ledger.pl -f $FileMatches -i $tmpfile.clean

It does not work anymore...

Best regards,
  Seb

-- 
Sebastien Vauban


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-01  6:50     ` Sebastien Vauban
@ 2011-08-01  7:28       ` Csaba Raduly
  2011-08-02 11:58         ` Sebastien Vauban
  2011-08-05 16:05       ` Andrey Repin
  1 sibling, 1 reply; 32+ messages in thread
From: Csaba Raduly @ 2011-08-01  7:28 UTC (permalink / raw)
  To: cygwin

On Mon, Aug 1, 2011 at 8:49 AM, Sebastien Vauban  wrote:
>
> Hi Andrey,
>
> Andrey Repin wrote:
> >>> For every shell code that I write, I'd like it to be portable both to
> >>> Cygwin on Windows, and to Ubuntu Linux for example.
> >>>
> >>> It's kinda possible, but am blocked with such a use case:
> >>>
> >>> alias vpnup='exec sudo openvpn --config ~/config/client.vpn --writepid /tmp/openvpn.pid &'
> >>>
> >>> While this worked perfectly under Ubuntu, I've had to make up a customized
> >>> version for Windows:
> >>>
> >>> alias vpnupwin='cd c:/home/sva/config; openvpn --config client.vpn --writepid c:/cygwin/tmp/openvpn.pid &'
> >
> >> Don't use Win32 paths.  Use POSIX paths:
> >
> >>   alias vpnupwin='cd /cygdrive/c/home/sva/config; openvpn --config client.vpn --writepid /cygdrive/c/cygwin/tmp/openvpn.pid &'
> >
> > Moreover, the very first line is wrong.
> >
> > Must be
> >
> > alias vpnup='exec sudo openvpn --config $HOME/config/client.vpn --writepid /tmp/openvpn.pid &'
> >
> > that's where his problem began, IMO.
>
> That's interesting. I thought this was completely equivalent (~ or $HOME), and
> preferred the shorter version.
>
> But you say it's not. Can you comment on this?  Thanks in advance...
>

bash.info   Tilde expansion:
"If a word begins with an unquoted tilde character (`~'), all of the
characters up to the first unquoted slash (or all characters, if there
is no unquoted slash) are considered a TILDE-PREFIX."

Note "word begins". I've been bitten by this in a makefile:

OPENSSL_DIR := ~/lib/openssl
CPPFLAGS := -I$(OPENSSL_DIR)

The gcc command line then contained -I~/lib/openssl, and the ~ was not
expanded by the shell. ${HOME}/lib/openssl would have worked.

If you want the same alias to work on Cygwin and Linux, you should set
up your $HOME on Cygwin to contain config/client.vpn
You can set your home in /etc/passwd and point it to /cygdrive/c/home
(this may have been mentioned already).
The idea is to always refer to the VPN config as
${HOME}/config/client.vpn and ensure that Cygwin can access it that
way.

Hope this helps,
Csaba
--
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-01  7:00   ` Sebastien Vauban
@ 2011-08-01  7:44     ` Corinna Vinschen
  2011-08-02 12:11       ` Sebastien Vauban
  2011-08-02 12:23       ` Sebastien Vauban
  2011-08-01  9:21     ` Thorsten Kampe
  1 sibling, 2 replies; 32+ messages in thread
From: Corinna Vinschen @ 2011-08-01  7:44 UTC (permalink / raw)
  To: cygwin

On Aug  1 08:46, Sebastien Vauban wrote:
> Hi Corinna,
> 
> Corinna Vinschen wrote:
> >> alias vpnup='exec sudo openvpn --config ~/config/client.vpn --writepid /tmp/openvpn.pid &'
> >> 
> >> While this worked perfectly under Ubuntu, I've had to make up a customized
> >> version for Windows:
> >> 
> >> alias vpnupwin='cd c:/home/sva/config; openvpn --config client.vpn --writepid c:/cygwin/tmp/openvpn.pid &'
> >
> > Don't use Win32 paths.  Use POSIX paths:
> >
> >   alias vpnupwin='cd /cygdrive/c/home/sva/config; openvpn --config client.vpn --writepid /cygdrive/c/cygwin/tmp/openvpn.pid &'
> 
> But, if I write it like that, this never will work under Ubuntu, does it?  Or
> is it possible with some "mount" magic to void the prefix "/cydgrive/c"?

How is that different from using a drive letter like C:?  The best you
can do is to create a mount point(*) under Cygwin which has the same
path as under Ubuntu.  Then, just use the same POSIX paths on both
systems.

> My goal is to have just 1 alias that would work both under Win32 (Cygwin) and
> Ubuntu, having the files located in the same place (relative to my home dir).
> 
> I also tried you suggestion for another command, which was:
> 
>     perl C:/home/sva/src/csv2ledger/CSV2Ledger.pl -f $FileMatches -i $tmpfile.clean
> 
> This works fine under Cygwin right now.
> 
> Rewritten with POSIX paths:
> 
>     perl /cygdrive/c/home/sva/src/csv2ledger/CSV2Ledger.pl -f $FileMatches -i $tmpfile.clean
> 
> It does not work anymore...

So you're not using Cygwin perl, or you changed your cygdrive prefix(**).


Corinna

(*) http://cygwin.com/cygwin-ug-net/using.html#mount-table
(**) http://cygwin.com/cygwin-ug-net/using.html#cygdrive

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-01  7:00   ` Sebastien Vauban
  2011-08-01  7:44     ` Corinna Vinschen
@ 2011-08-01  9:21     ` Thorsten Kampe
  2011-08-02 12:25       ` Sebastien Vauban
  1 sibling, 1 reply; 32+ messages in thread
From: Thorsten Kampe @ 2011-08-01  9:21 UTC (permalink / raw)
  To: cygwin

* Sebastien Vauban (Mon, 01 Aug 2011 08:46:52 +0200)
> My goal is to have just 1 alias that would work both under Win32
> (Cygwin) and Ubuntu

Why don't have simply put your alias definitions in if [[ $OSTYPE = 
cygwin ]]; then else"?

Thorsten


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-01  7:28       ` Csaba Raduly
@ 2011-08-02 11:58         ` Sebastien Vauban
  2011-08-02 12:36           ` Sebastien Vauban
  0 siblings, 1 reply; 32+ messages in thread
From: Sebastien Vauban @ 2011-08-02 11:58 UTC (permalink / raw)
  To: cygwin

Hi Csaba,

Csaba Raduly wrote:
> On Mon, Aug 1, 2011 at 8:49 AM, Sebastien Vauban  wrote:
>> Andrey Repin wrote:
>>> Moreover, the very first line is wrong.
>>>
>>> Must be
>>>
>>> alias vpnup='exec sudo openvpn --config $HOME/config/client.vpn --writepid /tmp/openvpn.pid &'
>>>
>>> that's where his problem began, IMO.
>>
>> That's interesting. I thought this was completely equivalent (~ or $HOME),
>> and preferred the shorter version.
>>
>> But you say it's not. Can you comment on this?  Thanks in advance...
>
> bash.info   Tilde expansion:
> "If a word begins with an unquoted tilde character (`~'), all of the
> characters up to the first unquoted slash (or all characters, if there
> is no unquoted slash) are considered a TILDE-PREFIX."
>
> Note "word begins". I've been bitten by this in a makefile:
>
> OPENSSL_DIR := ~/lib/openssl
> CPPFLAGS := -I$(OPENSSL_DIR)
>
> The gcc command line then contained -I~/lib/openssl, and the ~ was not
> expanded by the shell. ${HOME}/lib/openssl would have worked.

Excellent explanation. I was totally unaware of this.

> If you want the same alias to work on Cygwin and Linux, you should set
> up your $HOME on Cygwin to contain config/client.vpn
> You can set your home in /etc/passwd and point it to /cygdrive/c/home
> (this may have been mentioned already).
> The idea is to always refer to the VPN config as
> ${HOME}/config/client.vpn and ensure that Cygwin can access it that
> way.

I, maybe, have done it the completely wrong way(TM). As it currently is, I've
defined an environment variable in Windows itself:

    HOME=c:/home/sva

I did not touch so far /etc/passwd. The only visible effect of this is that
when firing up a bash terminal, the default directory is set to:

    c:/Documents and Settings/Sebastien

OK, I will update my HOME directory in /etc/passwd. Thanks for the reminder.
Do I have, though, to define HOME in Windows, in Cygwin (.bashrc or such), or
nowhere?

Best regards,
  Seb

-- 
Sebastien Vauban


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-01  7:44     ` Corinna Vinschen
@ 2011-08-02 12:11       ` Sebastien Vauban
  2011-08-02 12:23       ` Sebastien Vauban
  1 sibling, 0 replies; 32+ messages in thread
From: Sebastien Vauban @ 2011-08-02 12:11 UTC (permalink / raw)
  To: cygwin

Hi Corinna,

Corinna Vinschen wrote:
> On Aug  1 08:46, Sebastien Vauban wrote:
>> Corinna Vinschen wrote:
>> >> alias vpnup='exec sudo openvpn --config ~/config/client.vpn --writepid /tmp/openvpn.pid &'
>> >> 
>> >> While this worked perfectly under Ubuntu, I've had to make up a customized
>> >> version for Windows:
>> >> 
>> >> alias vpnupwin='cd c:/home/sva/config; openvpn --config client.vpn --writepid c:/cygwin/tmp/openvpn.pid &'
>> >
>> > Don't use Win32 paths.  Use POSIX paths:
>> >
>> >   alias vpnupwin='cd /cygdrive/c/home/sva/config; openvpn --config client.vpn --writepid /cygdrive/c/cygwin/tmp/openvpn.pid &'
>> 
>> But, if I write it like that, this never will work under Ubuntu, does it?  Or
>> is it possible with some "mount" magic to void the prefix "/cydgrive/c"?
>
> How is that different from using a drive letter like C:?

It's not. Simply, both did not work in a portable way.

> The best you can do is to create a mount point(*) under Cygwin which has the
> same path as under Ubuntu. Then, just use the same POSIX paths on both
> systems.
>
>> My goal is to have just 1 alias that would work both under Win32 (Cygwin)
>> and Ubuntu, having the files located in the same place (relative to my home
>> dir).
>> 
>> I also tried you suggestion for another command, which was:
>> 
>>     perl C:/home/sva/src/csv2ledger/CSV2Ledger.pl -f $FileMatches -i $tmpfile.clean
>> 
>> This works fine under Cygwin right now.
>> 
>> Rewritten with POSIX paths:
>> 
>>     perl /cygdrive/c/home/sva/src/csv2ledger/CSV2Ledger.pl -f $FileMatches -i $tmpfile.clean
>> 
>> It does not work anymore...
>
> So you're not using Cygwin perl, or you changed your cygdrive prefix(**).

I'm not. I don't know why but, when I installed Perl (months ago), I did not
think at looking in Cygwin packages. Seems I'm bad!

Best regards,
  Seb

-- 
Sebastien Vauban


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-01  7:44     ` Corinna Vinschen
  2011-08-02 12:11       ` Sebastien Vauban
@ 2011-08-02 12:23       ` Sebastien Vauban
  2011-08-02 14:37         ` Corinna Vinschen
  1 sibling, 1 reply; 32+ messages in thread
From: Sebastien Vauban @ 2011-08-02 12:23 UTC (permalink / raw)
  To: cygwin

Hi Corinna Vinschen,

Corinna Vinschen wrote:
> How is that different from using a drive letter like C:? The best you can do
> is to create a mount point(*) under Cygwin which has the same path as under
> Ubuntu. Then, just use the same POSIX paths on both systems.

As I put all my files starting at c:/home/sva, I'd then to mount

    C: = /

right?

So that my home directory under Ubuntu (/home/sva) is the same under Cygwin
(/home/sva = C:/home/sva).

Though, the following did not succeed:

#+begin_src sh
$ mount C: / -o binary
mount: warning: couldn't determine mount type.
mount: /: Operation not permitted
#+end_src

Is this operation really not permitted?

Best regards,
  Seb

-- 
Sebastien Vauban


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-01  9:21     ` Thorsten Kampe
@ 2011-08-02 12:25       ` Sebastien Vauban
  2011-08-02 15:41         ` Eliot Moss
  2011-08-08  1:20         ` Sven Köhler
  0 siblings, 2 replies; 32+ messages in thread
From: Sebastien Vauban @ 2011-08-02 12:25 UTC (permalink / raw)
  To: cygwin

Hi Thorsten,

Thorsten Kampe wrote:
> * Sebastien Vauban (Mon, 01 Aug 2011 08:46:52 +0200)
>> My goal is to have just 1 alias that would work both under Win32
>> (Cygwin) and Ubuntu
>
> Why don't have simply put your alias definitions in if [[ $OSTYPE = 
> cygwin ]]; then else"?

Because I really want one single definition which could work on every system
I'm using.

I don't like copy/pasting things, and just changing bits of the code, if I can
avoid it.

And this is not only for aliases. I'd like my shell scripts in general to be
able to run in whichever PC I'm on, be it Ubuntu or Windows.

Best regards,
  Seb

-- 
Sebastien Vauban


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-02 11:58         ` Sebastien Vauban
@ 2011-08-02 12:36           ` Sebastien Vauban
  0 siblings, 0 replies; 32+ messages in thread
From: Sebastien Vauban @ 2011-08-02 12:36 UTC (permalink / raw)
  To: cygwin

Hi Csaba,

"Sebastien Vauban" wrote:
> Csaba Raduly wrote:
>> On Mon, Aug 1, 2011 at 8:49 AM, Sebastien Vauban  wrote:
>>> Andrey Repin wrote:
>>>> Moreover, the very first line is wrong.
>>>>
>>>> Must be
>>>>
>>>> alias vpnup='exec sudo openvpn --config $HOME/config/client.vpn --writepid /tmp/openvpn.pid &'
>>>>
>>>> that's where his problem began, IMO.
>>
>> If you want the same alias to work on Cygwin and Linux, you should set
>> up your $HOME on Cygwin to contain config/client.vpn
>> You can set your home in /etc/passwd and point it to /cygdrive/c/home
>> (this may have been mentioned already).
>> The idea is to always refer to the VPN config as
>> ${HOME}/config/client.vpn and ensure that Cygwin can access it that
>> way.
>
> I, maybe, have done it the completely wrong way(TM). As it currently is, I've
> defined an environment variable in Windows itself:
>
>     HOME=c:/home/sva
>
> I did not touch so far /etc/passwd. The only visible effect of this is that
> when firing up a bash terminal, the default directory is set to:
>
>     c:/Documents and Settings/Sebastien
>
> OK, I will update my HOME directory in /etc/passwd. Thanks for the reminder.

Just wanted to do the above. Though, I just realized I had already done it --
months ago, then:

Sebastien:unused:1007:513:Fabrice,U-MEDIACENTER\Fabrice,S-1-5-21-57802372-1363436062-342225281-1007:/cygdrive/c/home/sva:/bin/bash

So, the fact the default directory is set to the Windows one is not due to it.

> Do I have, though, to define HOME in Windows, in Cygwin (.bashrc or such), or
> nowhere?

Best regards,
  Seb

-- 
Sebastien Vauban


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-02 12:23       ` Sebastien Vauban
@ 2011-08-02 14:37         ` Corinna Vinschen
  0 siblings, 0 replies; 32+ messages in thread
From: Corinna Vinschen @ 2011-08-02 14:37 UTC (permalink / raw)
  To: cygwin

On Aug  2 14:22, Sebastien Vauban wrote:
> Hi Corinna Vinschen,
> 
> Corinna Vinschen wrote:
> > How is that different from using a drive letter like C:? The best you can do
> > is to create a mount point(*) under Cygwin which has the same path as under
> > Ubuntu. Then, just use the same POSIX paths on both systems.
> 
> As I put all my files starting at c:/home/sva, I'd then to mount
> 
>     C: = /
> 
> right?

Wrong.  Don't change the root mount point.

> So that my home directory under Ubuntu (/home/sva) is the same under Cygwin
> (/home/sva = C:/home/sva).
> 
> Though, the following did not succeed:
> 
> #+begin_src sh
> $ mount C: / -o binary
> mount: warning: couldn't determine mount type.
> mount: /: Operation not permitted
> #+end_src
> 
> Is this operation really not permitted?

Don't do this.  Add a mount point to /home to your fstab.

Did you *read* the User's Guide?  In my previous mail I pasted two
links for your convenience.  For good measure I add another one:

http://cygwin.com/cygwin-ug-net/using.html#mount-table
http://cygwin.com/cygwin-ug-net/using.html#cygdrive
http://cygwin.com/cygwin-ug-net/using-utils.html#mount


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-02 12:25       ` Sebastien Vauban
@ 2011-08-02 15:41         ` Eliot Moss
  2011-08-02 20:05           ` Thorsten Kampe
  2011-08-08  1:20         ` Sven Köhler
  1 sibling, 1 reply; 32+ messages in thread
From: Eliot Moss @ 2011-08-02 15:41 UTC (permalink / raw)
  To: cygwin

On 8/2/2011 8:24 AM, Sebastien Vauban wrote:
> Hi Thorsten,
>
> Thorsten Kampe wrote:
>> * Sebastien Vauban (Mon, 01 Aug 2011 08:46:52 +0200)
>>> My goal is to have just 1 alias that would work both under Win32
>>> (Cygwin) and Ubuntu
>>
>> Why don't have simply put your alias definitions in if [[ $OSTYPE =
>> cygwin ]]; then else"?
>
> Because I really want one single definition which could work on every system
> I'm using.
>
> I don't like copy/pasting things, and just changing bits of the code, if I can
> avoid it.
>
> And this is not only for aliases. I'd like my shell scripts in general to be
> able to run in whichever PC I'm on, be it Ubuntu or Windows.

I get that -- I really do.  The suggestion to use a few conditionals
that look at the which OS you're on does not involve continued tweaking.
Once you have the right file, it works everywhere (for which you have
provided suitable cases) using the exact same file. It's just that
different parts get executed on different platforms.  It's not as
elegant as achieving an arrangement with no conditionals, but it's
practical and flexible. I've done it for years myself!

Regards -- Eliot Moss

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-02 15:41         ` Eliot Moss
@ 2011-08-02 20:05           ` Thorsten Kampe
  2011-08-02 20:45             ` Christopher Faylor
  2011-08-03 16:23             ` Andy Hall
  0 siblings, 2 replies; 32+ messages in thread
From: Thorsten Kampe @ 2011-08-02 20:05 UTC (permalink / raw)
  To: cygwin

* Eliot Moss (Tue, 02 Aug 2011 11:40:44 -0400)
> On 8/2/2011 8:24 AM, Sebastien Vauban wrote:
> > Thorsten Kampe wrote:
> >> * Sebastien Vauban (Mon, 01 Aug 2011 08:46:52 +0200)
> >>> My goal is to have just 1 alias that would work both under Win32
> >>> (Cygwin) and Ubuntu
> >>
> >> Why don't have simply put your alias definitions in if [[ $OSTYPE =
> >> cygwin ]]; then else"?
> >
> > Because I really want one single definition which could work on
> > every system I'm using.
[...]
> The suggestion to use a few conditionals that look at the which OS
> you're on does not involve continued tweaking. Once you have the right
> file, it works everywhere (for which you have provided suitable cases)
> using the exact same file. It's just that different parts get executed
> on different platforms. It's not as elegant as achieving an
> arrangement with no conditionals, but it's practical and flexible.

Couldn't have said it better. Cygwin is not Linux and you just can't 
ignore the differences. For example I have different aliases for netstat 
and ps on Linux and on Windows. They just don't have the same options. 

Thorsten


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-02 20:05           ` Thorsten Kampe
@ 2011-08-02 20:45             ` Christopher Faylor
  2011-08-03 16:23             ` Andy Hall
  1 sibling, 0 replies; 32+ messages in thread
From: Christopher Faylor @ 2011-08-02 20:45 UTC (permalink / raw)
  To: cygwin

On Tue, Aug 02, 2011 at 10:04:43PM +0200, Thorsten Kampe wrote:
>* Eliot Moss (Tue, 02 Aug 2011 11:40:44 -0400)
>> On 8/2/2011 8:24 AM, Sebastien Vauban wrote:
>> > Thorsten Kampe wrote:
>> >> * Sebastien Vauban (Mon, 01 Aug 2011 08:46:52 +0200)
>> >>> My goal is to have just 1 alias that would work both under Win32
>> >>> (Cygwin) and Ubuntu
>> >>
>> >> Why don't have simply put your alias definitions in if [[ $OSTYPE =
>> >> cygwin ]]; then else"?
>> >
>> > Because I really want one single definition which could work on
>> > every system I'm using.
>[...]
>> The suggestion to use a few conditionals that look at the which OS
>> you're on does not involve continued tweaking. Once you have the right
>> file, it works everywhere (for which you have provided suitable cases)
>> using the exact same file. It's just that different parts get executed
>> on different platforms. It's not as elegant as achieving an
>> arrangement with no conditionals, but it's practical and flexible.
>
>Couldn't have said it better. Cygwin is not Linux and you just can't 
>ignore the differences. For example I have different aliases for netstat 
>and ps on Linux and on Windows. They just don't have the same options. 

ps does, if you "alias ps=procps".

cgf

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* RE: Portable shell code between Cygwin and Linux
  2011-08-02 20:05           ` Thorsten Kampe
  2011-08-02 20:45             ` Christopher Faylor
@ 2011-08-03 16:23             ` Andy Hall
  1 sibling, 0 replies; 32+ messages in thread
From: Andy Hall @ 2011-08-03 16:23 UTC (permalink / raw)
  To: cygwin

> * Eliot Moss (Tue, 02 Aug 2011 11:40:44 -0400)
> > On 8/2/2011 8:24 AM, Sebastien Vauban wrote:
> > > Thorsten Kampe wrote:
> > >> * Sebastien Vauban (Mon, 01 Aug 2011 08:46:52 +0200)
> > >>> My goal is to have just 1 alias that would work both under Win32
> > >>> (Cygwin) and Ubuntu
> > >>
> > >> Why don't have simply put your alias definitions in if [[ $OSTYPE =
> > >> cygwin ]]; then else"?
> > >
> > > Because I really want one single definition which could work on
> > > every system I'm using.
> [...]
> > The suggestion to use a few conditionals that look at the which OS
> > you're on does not involve continued tweaking. Once you have the right
> > file, it works everywhere (for which you have provided suitable cases)
> > using the exact same file. It's just that different parts get executed
> > on different platforms. It's not as elegant as achieving an
> > arrangement with no conditionals, but it's practical and flexible.
> 
> Couldn't have said it better. Cygwin is not Linux and you just can't
> ignore the differences. For example I have different aliases for netstat
> and ps on Linux and on Windows. They just don't have the same options.
> 
> Thorsten
> 
I second this.  I have used that same technique since the late 80s to build
scripts that run on multiple platforms including Cygwin, Linux, Solaris,
HP-UX and AIX.  You can cover up all sorts of differences that way.  Its
about the only clean way of dealing with platform specific differences.  And
sadly, you may even have to stick with /bin/sh if you really want to be
portable.

Andy Hall


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-01  6:50     ` Sebastien Vauban
  2011-08-01  7:28       ` Csaba Raduly
@ 2011-08-05 16:05       ` Andrey Repin
  1 sibling, 0 replies; 32+ messages in thread
From: Andrey Repin @ 2011-08-05 16:05 UTC (permalink / raw)
  To: Sebastien Vauban, cygwin

Greetings, Sebastien Vauban!

>> Must be
>>
>> alias vpnup='exec sudo openvpn --config $HOME/config/client.vpn --writepid /tmp/openvpn.pid &'
>>
>> that's where his problem began, IMO.

> That's interesting. I thought this was completely equivalent (~ or $HOME), and
> preferred the shorter version.

For bash, that's true.
But for POSIX shell, or any other random shell - I doubt that much.
Anyway, if you want to write portable script, use POSIX shell syntax.
Yes, you'd lack some shortcuts, but the end result will be that your script is
more likely to work on random system, than not.


--
WBR,
 Andrey Repin (anrdaemon@freemail.ru) 05.08.2011, <19:56>

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-07-30 12:20   ` Andrey Repin
  2011-08-01  6:50     ` Sebastien Vauban
@ 2011-08-08  1:16     ` Sven Köhler
  2011-08-08  2:07       ` Eliot Moss
  2011-08-08  8:20       ` Andrey Repin
  1 sibling, 2 replies; 32+ messages in thread
From: Sven Köhler @ 2011-08-08  1:16 UTC (permalink / raw)
  To: cygwin

Am 30.07.2011 14:14, schrieb Andrey Repin:
> Greetings, Corinna Vinschen!
> 
>>> For every shell code that I write, I'd like it to be portable both to Cygwin
>>> on Windows, and to Ubuntu Linux for example.
>>>
>>> It's kinda possible, but am blocked with such a use case:
>>>
>>> alias vpnup='exec sudo openvpn --config ~/config/client.vpn --writepid /tmp/openvpn.pid &'
>>>
>>> While this worked perfectly under Ubuntu, I've had to make up a customized
>>> version for Windows:
>>>
>>> alias vpnupwin='cd c:/home/sva/config; openvpn --config client.vpn --writepid c:/cygwin/tmp/openvpn.pid &'
> 
>> Don't use Win32 paths.  Use POSIX paths:
> 
>>   alias vpnupwin='cd /cygdrive/c/home/sva/config; openvpn --config client.vpn --writepid /cygdrive/c/cygwin/tmp/openvpn.pid &'
> 
> Moreover, the very first line is wrong.
> 
> Must be
> 
> alias vpnup='exec sudo openvpn --config $HOME/config/client.vpn --writepid /tmp/openvpn.pid &'
> 
> that's where his problem began, IMO.

I don't know, why you pointed that out. It's of no use to feed a path
like $HOME/something to a pure win32 binary.
(Certainly, this hint is kind of important for the ubuntu version of the
script, but not for the cygwin issue, which is solely because he's
mixing cygwin and win32 and expects it work without any complication)


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-02 12:25       ` Sebastien Vauban
  2011-08-02 15:41         ` Eliot Moss
@ 2011-08-08  1:20         ` Sven Köhler
  2011-08-08 13:41           ` Eric Blake
  1 sibling, 1 reply; 32+ messages in thread
From: Sven Köhler @ 2011-08-08  1:20 UTC (permalink / raw)
  To: cygwin

Am 02.08.2011 14:24, schrieb Sebastien Vauban:
> I don't like copy/pasting things, and just changing bits of the code, if I can
> avoid it.

if you detect cygwin:

pathconvert() {
  // do cygwin specific path conversion of $1
}

if you don't detect cygwin

pathconvert() {
  echo "$1"
}


Use the pathconvert command whereever you pass full qualified paths from
cygwin to win32.

(There's one issue here: I would like to write echo -- "$1", but echo
doesn't understand --. Bummer.)


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-08  1:16     ` Sven Köhler
@ 2011-08-08  2:07       ` Eliot Moss
  2011-08-08 22:17         ` Gary Johnson
  2011-08-08  8:20       ` Andrey Repin
  1 sibling, 1 reply; 32+ messages in thread
From: Eliot Moss @ 2011-08-08  2:07 UTC (permalink / raw)
  To: cygwin

On 8/7/2011 9:16 PM, Sven Köhler wrote:
> Am 30.07.2011 14:14, schrieb Andrey Repin:
>> Greetings, Corinna Vinschen!
>>
>>>> For every shell code that I write, I'd like it to be portable both to Cygwin
>>>> on Windows, and to Ubuntu Linux for example.
>>>>
>>>> It's kinda possible, but am blocked with such a use case:
>>>>
>>>> alias vpnup='exec sudo openvpn --config ~/config/client.vpn --writepid /tmp/openvpn.pid&'
>>>>
>>>> While this worked perfectly under Ubuntu, I've had to make up a customized
>>>> version for Windows:
>>>>
>>>> alias vpnupwin='cd c:/home/sva/config; openvpn --config client.vpn --writepid c:/cygwin/tmp/openvpn.pid&'
>>
>>> Don't use Win32 paths.  Use POSIX paths:
>>
>>>    alias vpnupwin='cd /cygdrive/c/home/sva/config; openvpn --config client.vpn --writepid /cygdrive/c/cygwin/tmp/openvpn.pid&'
>>
>> Moreover, the very first line is wrong.
>>
>> Must be
>>
>> alias vpnup='exec sudo openvpn --config $HOME/config/client.vpn --writepid /tmp/openvpn.pid&'
>>
>> that's where his problem began, IMO.
>
> I don't know, why you pointed that out. It's of no use to feed a path
> like $HOME/something to a pure win32 binary.
> (Certainly, this hint is kind of important for the ubuntu version of the
> script, but not for the cygwin issue, which is solely because he's
> mixing cygwin and win32 and expects it work without any complication)

The OP *was* seeking uniform scripts between cygwin and ubuntu, but where
some of the programs invoked under cygwin are Windows programs (which
therefore need Windows paths, etc.).  But in any case, setting up
suitable environment variables, aliases, etc., in a section of setup
scripts that tests uname seems to be the agreed advice, along with
specifics concerning cygpath and settings for particular programs ...

Best wishes -- Eliot moss

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-08  1:16     ` Sven Köhler
  2011-08-08  2:07       ` Eliot Moss
@ 2011-08-08  8:20       ` Andrey Repin
  2011-08-08  9:11         ` Sven Köhler
  1 sibling, 1 reply; 32+ messages in thread
From: Andrey Repin @ 2011-08-08  8:20 UTC (permalink / raw)
  To: Sven Köhler, cygwin

Greetings, Sven Köhler!

>> alias vpnup='exec sudo openvpn --config $HOME/config/client.vpn --writepid /tmp/openvpn.pid &'
>> 
>> that's where his problem began, IMO.

> I don't know, why you pointed that out. It's of no use to feed a path
> like $HOME/something to a pure win32 binary.

You DON'T "feed a path like $HOME/something" !
The shell that run the script will expand variable before passing it to the
program.

> (Certainly, this hint is kind of important for the ubuntu version of the
> script, but not for the cygwin issue, which is solely because he's
> mixing cygwin and win32 and expects it work without any complication)

Not true.


--
WBR,
 Andrey Repin (anrdaemon@freemail.ru) 08.08.2011, <12:13>

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-08  8:20       ` Andrey Repin
@ 2011-08-08  9:11         ` Sven Köhler
  2011-08-08 14:27           ` Eliot Moss
  0 siblings, 1 reply; 32+ messages in thread
From: Sven Köhler @ 2011-08-08  9:11 UTC (permalink / raw)
  To: cygwin; +Cc: Andrey Repin

[-- Attachment #1: Type: text/plain, Size: 906 bytes --]

Am 08.08.2011 10:14, schrieb Andrey Repin:
> Greetings, Sven Köhler!
> 
>>> alias vpnup='exec sudo openvpn --config $HOME/config/client.vpn --writepid /tmp/openvpn.pid &'
>>>
>>> that's where his problem began, IMO.
> 
>> I don't know, why you pointed that out. It's of no use to feed a path
>> like $HOME/something to a pure win32 binary.
> 
> You DON'T "feed a path like $HOME/something" !
> The shell that run the script will expand variable before passing it to the
> program.

A win32 (non-cygwin) executable doesn't that /cygdrive/c refers to c:\.
It also doesn't know that /home/bla is actually the same as
c:\cygwin\home\bla. A win32 simply doesn't use cygwin, hence don't know
about the translation from cygwin's POSIX paths to win32 ones.

It turned out, that the OP was not using a cygwin version of openvpn.
So if $HOME is a POSIX (cygwin specific) path, it won't work.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-08  1:20         ` Sven Köhler
@ 2011-08-08 13:41           ` Eric Blake
  2011-08-10 12:03             ` Sven Köhler
  0 siblings, 1 reply; 32+ messages in thread
From: Eric Blake @ 2011-08-08 13:41 UTC (permalink / raw)
  To: cygwin

On 08/07/2011 07:20 PM, Sven Köhler wrote:
> pathconvert() {
>    echo "$1"
> }
>

> (There's one issue here: I would like to write echo -- "$1", but echo
> doesn't understand --. Bummer.)

echo _cannot_ be used to portably echo arbitrary strings.  For that, you 
need printf:

pathconvert() {
   printf '%s\n' "$1"
}

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-08  9:11         ` Sven Köhler
@ 2011-08-08 14:27           ` Eliot Moss
  0 siblings, 0 replies; 32+ messages in thread
From: Eliot Moss @ 2011-08-08 14:27 UTC (permalink / raw)
  To: cygwin

On 8/8/2011 5:11 AM, Sven Köhler wrote:
> Am 08.08.2011 10:14, schrieb Andrey Repin:
>> Greetings, Sven Köhler!
>>
>>>> alias vpnup='exec sudo openvpn --config $HOME/config/client.vpn --writepid /tmp/openvpn.pid&'
>>>>
>>>> that's where his problem began, IMO.
>>
>>> I don't know, why you pointed that out. It's of no use to feed a path
>>> like $HOME/something to a pure win32 binary.
>>
>> You DON'T "feed a path like $HOME/something" !
>> The shell that run the script will expand variable before passing it to the
>> program.
>
> A win32 (non-cygwin) executable doesn't that /cygdrive/c refers to c:\.
> It also doesn't know that /home/bla is actually the same as
> c:\cygwin\home\bla. A win32 simply doesn't use cygwin, hence don't know
> about the translation from cygwin's POSIX paths to win32 ones.
>
> It turned out, that the OP was not using a cygwin version of openvpn.
> So if $HOME is a POSIX (cygwin specific) path, it won't work.

Hence my remark that you also have to know about and use (properly)
the cygpath utility, which can convert cygwin paths to ones for
Windows/DOS programs ...

Eliot Moss

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-08  2:07       ` Eliot Moss
@ 2011-08-08 22:17         ` Gary Johnson
  0 siblings, 0 replies; 32+ messages in thread
From: Gary Johnson @ 2011-08-08 22:17 UTC (permalink / raw)
  To: cygwin

On 2011-08-07, Eliot Moss wrote:
> On 8/7/2011 9:16 PM, Sven Köhler wrote:
> >Am 30.07.2011 14:14, schrieb Andrey Repin:
> >>Greetings, Corinna Vinschen!
> >>
> >>>>For every shell code that I write, I'd like it to be portable both to 
> >>>>Cygwin
> >>>>on Windows, and to Ubuntu Linux for example.
> >>>>
> >>>>It's kinda possible, but am blocked with such a use case:
> >>>>
> >>>>alias vpnup='exec sudo openvpn --config ~/config/client.vpn --writepid 
> >>>>/tmp/openvpn.pid&'
> >>>>
> >>>>While this worked perfectly under Ubuntu, I've had to make up a 
> >>>>customized
> >>>>version for Windows:
> >>>>
> >>>>alias vpnupwin='cd c:/home/sva/config; openvpn --config client.vpn 
> >>>>--writepid c:/cygwin/tmp/openvpn.pid&'
> >>
> >>>Don't use Win32 paths.  Use POSIX paths:
> >>
> >>>   alias vpnupwin='cd /cygdrive/c/home/sva/config; openvpn --config 
> >>>   client.vpn --writepid /cygdrive/c/cygwin/tmp/openvpn.pid&'
> >>
> >>Moreover, the very first line is wrong.
> >>
> >>Must be
> >>
> >>alias vpnup='exec sudo openvpn --config $HOME/config/client.vpn 
> >>--writepid /tmp/openvpn.pid&'
> >>
> >>that's where his problem began, IMO.
> >
> >I don't know, why you pointed that out. It's of no use to feed a path
> >like $HOME/something to a pure win32 binary.
> >(Certainly, this hint is kind of important for the ubuntu version of the
> >script, but not for the cygwin issue, which is solely because he's
> >mixing cygwin and win32 and expects it work without any complication)
> 
> The OP *was* seeking uniform scripts between cygwin and ubuntu, but where
> some of the programs invoked under cygwin are Windows programs (which
> therefore need Windows paths, etc.).  But in any case, setting up
> suitable environment variables, aliases, etc., in a section of setup
> scripts that tests uname seems to be the agreed advice, along with
> specifics concerning cygpath and settings for particular programs ...

Something else the OP may be able to use is Luc Hermitte's
cyg-wrapper.sh script.  It's designed to solve exactly this problem
of running a Windows program from a Cygwin environment.

    http://hermitte.free.fr/cygwin/

Regards,
Gary


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Portable shell code between Cygwin and Linux
  2011-08-08 13:41           ` Eric Blake
@ 2011-08-10 12:03             ` Sven Köhler
  0 siblings, 0 replies; 32+ messages in thread
From: Sven Köhler @ 2011-08-10 12:03 UTC (permalink / raw)
  To: cygwin

Am 08.08.2011 15:40, schrieb Eric Blake:
> On 08/07/2011 07:20 PM, Sven Köhler wrote:
>> pathconvert() {
>>    echo "$1"
>> }
>>
> 
>> (There's one issue here: I would like to write echo -- "$1", but echo
>> doesn't understand --. Bummer.)
> 
> echo _cannot_ be used to portably echo arbitrary strings.  For that, you
> need printf:
> 
> pathconvert() {
>   printf '%s\n' "$1"
> }

Thanks! I learned something.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2011-08-10 12:03 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-29 19:15 Portable shell code between Cygwin and Linux Sebastien Vauban
2011-07-29 19:45 ` Larry Hall (Cygwin)
2011-08-01  6:40   ` Sebastien Vauban
2011-07-29 19:47 ` Eliot Moss
2011-08-01  6:45   ` Sebastien Vauban
2011-07-29 20:17 ` Corinna Vinschen
2011-07-30 12:20   ` Andrey Repin
2011-08-01  6:50     ` Sebastien Vauban
2011-08-01  7:28       ` Csaba Raduly
2011-08-02 11:58         ` Sebastien Vauban
2011-08-02 12:36           ` Sebastien Vauban
2011-08-05 16:05       ` Andrey Repin
2011-08-08  1:16     ` Sven Köhler
2011-08-08  2:07       ` Eliot Moss
2011-08-08 22:17         ` Gary Johnson
2011-08-08  8:20       ` Andrey Repin
2011-08-08  9:11         ` Sven Köhler
2011-08-08 14:27           ` Eliot Moss
2011-08-01  7:00   ` Sebastien Vauban
2011-08-01  7:44     ` Corinna Vinschen
2011-08-02 12:11       ` Sebastien Vauban
2011-08-02 12:23       ` Sebastien Vauban
2011-08-02 14:37         ` Corinna Vinschen
2011-08-01  9:21     ` Thorsten Kampe
2011-08-02 12:25       ` Sebastien Vauban
2011-08-02 15:41         ` Eliot Moss
2011-08-02 20:05           ` Thorsten Kampe
2011-08-02 20:45             ` Christopher Faylor
2011-08-03 16:23             ` Andy Hall
2011-08-08  1:20         ` Sven Köhler
2011-08-08 13:41           ` Eric Blake
2011-08-10 12:03             ` Sven Köhler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).