0

I'm following The Unix Programming Environment exercises and have encountered some weird issues. While going through the ed exercise, when you just start ed, type in the exercise, then do

 w poem

It saves in the filesystem as 'poem ' I tested another file, start ed, type in some words,

w raistlin 

and it saves as 'raistlin ' with the same result (filename in single quotes followed by one space), though I tested on a third, and if I start off with the file name it saves as a normal file. Has anyone else seen these results? I know it's a little esoteric, I think I'm probably 1 of 7 people on the whole earth using ed this weekend. I'm using Manjaro Arch.

7
  • 1
    I can't reproduce this with GNU ed nor with the native ed on OpenBSD. Where do you see these filenames, is it in the ls output? What does printf '>>%s<<\n' * output for these files?
    – Kusalananda
    Commented Nov 28, 2020 at 8:49
  • Yes it's in the ls output. It gets's weirder I switched window managers from dwm to xfce and it seems have gone away. I was using terminator on dwm and now xfce-terminal. So it's a terminal issue??? Commented Nov 28, 2020 at 9:04
  • 1
    Could well be a terminal issue, yes, or something else relating to your graphical desktop setup. I can't unfortunately test identical setups to yours... Does text that you input get modified in a similar way in any other terminal application? (I'm guessing it's not actually related to ed but to something that your input is passing through).
    – Kusalananda
    Commented Nov 28, 2020 at 9:07
  • I thought I saw something weird in vi a few weeks ago, but didn't write it down. I'll test on my Debian system as well going back into dwm and testing with a couple of different terminal apps. Commented Nov 28, 2020 at 9:13
  • Could you check whether the odd filenames contains Unicode characters? Possibly by printf '%s\n' PATTERN | od -ah where PATTERN is some pattern that matches at least of the names.
    – Kusalananda
    Commented Nov 28, 2020 at 9:24

2 Answers 2

2

According to the originating user, they accidentally added a space character at the end of the filename when saving the file in ed.

w test 

(extra space typed after the test string above)

Doing so will provoke GNU ls to add single quotes around the filename in its output. It would do this to any filename that is "unusual". In this case, because it contains a space character.

$ ls -l
total 4
-rw-rw-r-- 1 myself myself 6 Mar  9 21:17 'test '

You can get GNU ls to output unquoted filenames if you wish, using either ls --literal, ls -N, ls --quoting-style=literal, or by setting the environment variable QUOTING_STYLE to the string literal. However, since ls output is only meant for looking at, it doesn't really matter.

Related:

1

Seems that it was an extra space after the filename. So when you specify the filename like this.

ed poem

it works fine. Inside ed be extremely careful when you are typing the commands like this:

w poem(enter)

... and not:

w poem (enter)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .