[Omake] How to pass an empty string to concat()?

Jason Hickey jyh at cs.caltech.edu
Sun Dec 2 10:10:13 PST 2007


On Dec 2, 2007, at 1:00 AM, Dmitry Bely wrote:

>> When you wrote d=$''... the string literal was never terminated.
>
> Why? What is the difference between $'' and $' ' (two single quotes in
> both cases)? And how to leave osh if I happen to write an unterminated
> string?

In OMake-style strings, the initial delimiter can have multiple  
characters; it is the longest contiguous sequence of quote symbols at  
the head.  The final delimiter has to have the same length.

     OMake-style string            equivalent C-style string
     $'ABC'                        "ABC"
     $'''ABC'''                    "ABC"
     $'''A'B'''                    "A'B"
     $""He said, "Hello world".""  "He said, \"Hello world\"."
     $"A 'quote'"                  "A 'quote'"
     $""""A multi-                 "A multi-\nline string, with  
\"garbage\"\nin it."
line string, with "garbage"
in it.""""

There is no way to write an empty string, or any string that begins or  
ends with the same kind of quote as the delimiters.  If you get caught  
in a quote, you should be able to get out of it with ^D (the end-of- 
file key, maybe ^Z on Windows).

Also, I suddenly realized that there is an easier way for you.  The  
function "split" can be used to split apart a string.

osh> concat(/, $(split \\, $'c:\Program Files\Objective Caml'))
- : <data "c:/Program Files/Objective Caml"> : String

Jason

--
Jason Hickey                  http://www.cs.caltech.edu/~jyh
Caltech Computer Science      Tel: 626-395-6568 FAX: 626-792-4257





More information about the Omake mailing list