On Smart Quotes and Terminal

Typography is a wonderful art and has a long history. When humans turned from manual typesetting to machines, type writers and then computers, some compromises had to be made. One of these compromises was to use simple straight quote symbols for opening and closing the quote, rather than different quote symbols for opening and closing.

Note: which kind of quotes are used for opening and closing dependent on the language or and some convention. English uses upper quotes “…”, German opens with a lower quote: „…“, French uses ‘guillemets:’ «…», and Japanese uses hooks: 「…」

Quotation Marks have funny names in many languages. Germans call them “Gänsefüßchen,” or “little goose feet.”

See this Wikipedia article for more details.

macOS, iOS and other modern operating systems have a feature which replaces the simple or straight quote symbols with the typographic quotes. So, you type "Hello!" and the quotes are automatically replaced with the proper (depending on localization) typographic quotes. This is called “smart quotes.”

This is pretty nice, but can be troublesome when dealing with Terminal and text editors. Scripting languages and shells always use straight quotes, and cannot deal with typographic quotes.

Now, if someone sends you a command or a script that uses quotes, and it goes through an app that replaces them with smart quotes, then bash and Terminal will fail miserably.

There is not much you can do, other than be aware of this and check pasted code carefully. There is something you can do to make this easier, though.

The default monospace font used in Terminal on macOS are ‘Menlo’ or ‘SF Mono,’ depending on the macOS version. Now these are fine typefaces, but their typographic quotes are not very curly at all, making them very hard to distinguish from the ‘dumb’ straight quotes that Terminal expects. The classic ‘Monaco’ typeface on the other hand has beautiful curly typographic quotes, making them very distinct from the the straight quote.

My favorite mono space typeface ‘Source Code Pro’ also has nice curly typographic quotes. I have built this table with many common monospace typefaces and their quotes.

Quotation Mark Comparison
Quotation Mark Comparison

Now this shouldn’t be your only criteria in choosing your Terminal font, but it may be something that helps avoid quote errors.

Published by

ab

Mac Admin, Consultant, and Author

2 thoughts on “On Smart Quotes and Terminal”

  1. Is there a way that you can get terminal to automatically replace smart quotes with dumb quotes when you paste in something? I store a lot of terminal commands (like ffmpeg to convert a m3u8 file to an mp4) in Stickies. When I paste it into terminal after modifying the URL and filename, it (dumbly – yes, pun intended) pastes with*out* dumb quotes, which causes it to fail.

    With ffmpeg, it cryptically fails with the ever-enigmatic error “[13] + suspended (tty output) ffmpeg -i” (Which makes no sense as there isn’t a background task – I don’t think). If I replace the quotes by hand in terminal, which doesn’t use SQ by default, it works. Example:

    ffmpeg -i “https://dp8hsntg6do36.cloudfront.net/5e56d89538d06922ac653cc0/fc1d5c8d-bf74-4e79-81cd-66bea22e88bbmanifest-ios.m3u8?videoIndex=0&requester=oo” -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 “Crash Bandicoot Hacked The Original Playstation.mp4”

    FAILS with first an error about trying to interpret “-bsf:a” as a command, and then the error about a suspended process:

    [14] 25561
    zsh: command not found: -bsf:a
    jswitte@Jamess-MacBook-Pro ~ % ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
    built with Apple clang version 11.0.0 (clang-1100.0.33.17)
    configuration: –prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 –enable-shared –enable-pthreads –enable-version3 –enable-avresample –cc=clang –host-cflags= –host-ldflags= –enable-ffplay –enable-gnutls –enable-gpl –enable-libaom –enable-libbluray –enable-libmp3lame –enable-libopus –enable-librubberband –enable-libsnappy –enable-libtesseract –enable-libtheora –enable-libvidstab –enable-libvorbis –enable-libvpx –enable-libwebp –enable-libx264 –enable-libx265 –enable-libxvid –enable-lzma –enable-libfontconfig –enable-libfreetype –enable-frei0r –enable-libass –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libopenjpeg –enable-librtmp –enable-libspeex –enable-libsoxr –enable-videotoolbox –disable-libjack –disable-indev=jack
    libavutil 56. 31.100 / 56. 31.100
    libavcodec 58. 54.100 / 58. 54.100
    libavformat 58. 29.100 / 58. 29.100
    libavdevice 58. 8.100 / 58. 8.100
    libavfilter 7. 57.100 / 7. 57.100
    libavresample 4. 0. 0 / 4. 0. 0
    libswscale 5. 5.100 / 5. 5.100
    libswresample 3. 5.100 / 3. 5.100
    libpostproc 55. 5.100 / 55. 5.100

    [14] + suspended (tty output) ffmpeg -i

    BUT,

    % ffmpeg -i “https://dp8hsntg6do36.cloudfront.net/5e56d89538d06922ac653cc0/fc1d5c8d-bf74-4e79-81cd-66bea22e88bbmanifest-ios.m3u8?videoIndex=0&requester=oo” -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 “Crash Bandicoot Hacked The Original Playstation.mp4”

    (I changed the smart quotes to dumb ones in Terminal itself), works:

    [[..]]

    [https @ 0x7faeaa034600] Opening ‘https://dp8hsntg6do36.cloudfront.net/5e56d89538d06922ac653cc0/fc1d5c8d-bf74-4e79-81cd-66bea22e88bbfile-200k-40-48000-400.m3u8’ for reading
    [hls @ 0x7faea9008a00] Skip (‘#ZEN-TOTAL-DURATION:1896.81159’)
    [hls @ 0x7faea9008a00] Skip (‘#ZEN-AVERAGE-BANDWIDTH:161942’)
    [hls @ 0x7faea9008a00] Skip (‘#ZEN-MAXIMUM-BANDWIDTH:233120’)

    [[..]]

    [https @ 0x7f8c3a1b4a00] Opening ‘https://dp8hsntg6do36.cloudfront.net/5e56d89538d06922ac653cc0/fc1d5c8d-bf74-4e79-81cd-66bea22e88bbfile-5872k-128-48000-1920-00316.ts’ for reading
    frame=45478 fps=313 q=-1.0 Lsize= 734423kB time=00:31:36.91 bitrate=3171.7kbits/s speed= 13x
    video:724259kB audio:9259kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.123329%
    jswitte@Jamess-MacBook-Pro ~ %

    1. No, you can tell the Notes app to not use smart quotes in the ‘Substititutions’ submenu of the ‘Edit’ Menu. Or use a different text editor to store your command snippets.

Comments are closed.