Skip to main content
More on FILES URL
Source Link
Allan
  • 104.4k
  • 33
  • 206
  • 470

I'm guessing that open thinks that the filename might be a URL.

You would be correct in that guess.

Unix/BSD/Linux/etc. (macOS is a certified Unix) don’t use characters for filenames. Instead, it’s an array of bytes. With the exception of a few characters like the Null character (0x00) and forward slash (0x2f - /) pretty much everything else is fair game including colons. In short, you can have colons in your filename and it be valid.

See this excellent post on Unix & Linux entitled Understanding Unix File Name Encoding for additional details.

Is there some way to force open to open the file by default if the file exists,

Unfortunately, no. Your operating system (macOS in this case) cannot tell the difference between a filename with a colon or a URL with a colon.

Why?

The problem here is that per the URL Specification (RFC-1738), §2.1, The main parts of URLs define what a URL is supposed to look like…

A URL contains the name of the scheme being used () followed by a colon and then a string (the ) whose interpretation depends on the scheme.

Emphasis Mine

if the file name matches a pattern that could conceivably be a URL?

A file is a file; that’s easy. A URL on the other hand, can be many things, including a file. See RFC-1738 §3.10 Files:

The file URL scheme is used to designate files accessible on a particular host computer. This scheme, unlike most other URL schemes, does not designate a resource that is universally accessible over the Internet.

A file URL can take the form of (VAX/VMS):

DISK$USER:[SHARE]FOO.BAR
         ꜛ
          Note the colon!

That’s a perfectly valid file and in this case, would be remote. However, due to how Unix allows every single one of the those characters to exist in a filename, the question (for the OS) is “how to handle it?” Open as a URL or open as a file? This is why you get the prompt.

TL;DR

You can’t force open to open a target as a file when the argument can be one of many things. In this case, a file with a colon could be either URL or it could be a file; thus the prompt you are seeing.

This is due to the “permissible characters” (byte arrays, actually) that make up a filename on Unix as well as the confusion created behind what a URL is defined as.

As for a “reverse” of open -u, well, that just doesn’t exist as an argument for the open command.

I'm guessing that open thinks that the filename might be a URL.

You would be correct in that guess.

Unix/BSD/Linux/etc. (macOS is a certified Unix) don’t use characters for filenames. Instead, it’s an array of bytes. With the exception of a few characters like the Null character (0x00) and forward slash (0x2f - /) pretty much everything else is fair game including colons. In short, you can have colons in your filename and it be valid.

See this excellent post on Unix & Linux entitled Understanding Unix File Name Encoding for additional details.

Is there some way to force open to open the file by default if the file exists,

Unfortunately, no. Your operating system (macOS in this case) cannot tell the difference between a filename with a colon or a URL with a colon.

Why?

The problem here is that per the URL Specification (RFC-1738), §2.1, The main parts of URLs define what a URL is supposed to look like…

A URL contains the name of the scheme being used () followed by a colon and then a string (the ) whose interpretation depends on the scheme.

Emphasis Mine

if the file name matches a pattern that could conceivably be a URL?

A file is a file; that’s easy. A URL on the other hand, can be many things, including a file. See RFC-1738 §3.10 Files:

The file URL scheme is used to designate files accessible on a particular host computer. This scheme, unlike most other URL schemes, does not designate a resource that is universally accessible over the Internet.

TL;DR

You can’t force open to open a target as a file when the argument can be one of many things. In this case, a file with a colon could be either URL or it could be a file; thus the prompt you are seeing.

This is due to the “permissible characters” (byte arrays, actually) that make up a filename on Unix as well as the confusion created behind what a URL is defined as.

As for a “reverse” of open -u, well, that just doesn’t exist as an argument for the open command.

I'm guessing that open thinks that the filename might be a URL.

You would be correct in that guess.

Unix/BSD/Linux/etc. (macOS is a certified Unix) don’t use characters for filenames. Instead, it’s an array of bytes. With the exception of a few characters like the Null character (0x00) and forward slash (0x2f - /) pretty much everything else is fair game including colons. In short, you can have colons in your filename and it be valid.

See this excellent post on Unix & Linux entitled Understanding Unix File Name Encoding for additional details.

Is there some way to force open to open the file by default if the file exists,

Unfortunately, no. Your operating system (macOS in this case) cannot tell the difference between a filename with a colon or a URL with a colon.

Why?

The problem here is that per the URL Specification (RFC-1738), §2.1, The main parts of URLs define what a URL is supposed to look like…

A URL contains the name of the scheme being used () followed by a colon and then a string (the ) whose interpretation depends on the scheme.

Emphasis Mine

if the file name matches a pattern that could conceivably be a URL?

A file is a file; that’s easy. A URL on the other hand, can be many things, including a file. See RFC-1738 §3.10 Files:

The file URL scheme is used to designate files accessible on a particular host computer. This scheme, unlike most other URL schemes, does not designate a resource that is universally accessible over the Internet.

A file URL can take the form of (VAX/VMS):

DISK$USER:[SHARE]FOO.BAR
         ꜛ
          Note the colon!

That’s a perfectly valid file and in this case, would be remote. However, due to how Unix allows every single one of the those characters to exist in a filename, the question (for the OS) is “how to handle it?” Open as a URL or open as a file? This is why you get the prompt.

TL;DR

You can’t force open to open a target as a file when the argument can be one of many things. In this case, a file with a colon could be either URL or it could be a file; thus the prompt you are seeing.

This is due to the “permissible characters” (byte arrays, actually) that make up a filename on Unix as well as the confusion created behind what a URL is defined as.

As for a “reverse” of open -u, well, that just doesn’t exist as an argument for the open command.

Added info on `open` and URL definitions.
Source Link
Allan
  • 104.4k
  • 33
  • 206
  • 470

I'm guessing that open thinks that the filename might be a URL.

You would be correct in that guess. Unix

Unix/BSD/Linux/etc. (macOS is a certified UnixmacOS is a certified Unix) don’t use characters for filenames. Instead, it’s an array of bytes. With the exception of a few characters like the Null character (0x00) and forward slash (0x2f - /) pretty much everything else is fair game including colons. In short, you can have colons in your filename and it be valid.

See this excellent post on Unix & Linux entitled Understanding Unix File Name Encoding for additional details.

Is there some way to force open to open the file by default if the file exists,

Unfortunately, no. Your operating system (macOS in this case) cannot tell the difference between a filename with a colon or a URL with a colon.

Why?

The problem here is that per the URL Specification (RFC-1738RFC-1738), §2.1, The main parts of URLs§2.1, The main parts of URLs define what a URL is supposed to look like…

A URL contains the name of the scheme being used () followed by a colon and then a string (the ) whose interpretation depends on the scheme.

Emphasis Mine

if the file name matches a pattern that could conceivably be a URL?

A file is a file; that’s easy. A URL on the other hand, can be many things, including a file. See RFC-1738 §3.10 Files:

The file URL scheme is used to designate files accessible on a particular host computer. This scheme, unlike most other URL schemes, does not designate a resource that is universally accessible over the Internet.

TL;DR

You can’t force open to open a target as a file when the argument can be one of many things. In this case, a file with a colon could be either URL or it could be a file; thus the prompt you are seeing.

This is due to the “permissible characters” (byte arrays, actually) that make up a filename on Unix as well as the confusion created behind what a URL is defined as.

As for a “reverse” of open -u, well, that just doesn’t exist as an argument for the open command.

I'm guessing that open thinks that the filename might be a URL.

You would be correct. Unix/BSD/Linux/etc. (macOS is a certified Unix) don’t use characters for filenames. Instead, it’s an array of bytes. With the exception of a few characters like the Null character (0x00) and forward slash (0x2f - /) pretty much everything else is fair game including colons.

Is there some way to force open to open the file by default if the file exists,

Unfortunately, no. Your operating system (macOS in this case) cannot tell the difference between a filename with a colon or a URL with a colon.

Why?

The problem here is that per the URL Specification (RFC-1738), §2.1, The main parts of URLs define what a URL is supposed to look like…

A URL contains the name of the scheme being used () followed by a colon and then a string (the ) whose interpretation depends on the scheme.

Emphasis Mine

I'm guessing that open thinks that the filename might be a URL.

You would be correct in that guess.

Unix/BSD/Linux/etc. (macOS is a certified Unix) don’t use characters for filenames. Instead, it’s an array of bytes. With the exception of a few characters like the Null character (0x00) and forward slash (0x2f - /) pretty much everything else is fair game including colons. In short, you can have colons in your filename and it be valid.

See this excellent post on Unix & Linux entitled Understanding Unix File Name Encoding for additional details.

Is there some way to force open to open the file by default if the file exists,

Unfortunately, no. Your operating system (macOS in this case) cannot tell the difference between a filename with a colon or a URL with a colon.

Why?

The problem here is that per the URL Specification (RFC-1738), §2.1, The main parts of URLs define what a URL is supposed to look like…

A URL contains the name of the scheme being used () followed by a colon and then a string (the ) whose interpretation depends on the scheme.

Emphasis Mine

if the file name matches a pattern that could conceivably be a URL?

A file is a file; that’s easy. A URL on the other hand, can be many things, including a file. See RFC-1738 §3.10 Files:

The file URL scheme is used to designate files accessible on a particular host computer. This scheme, unlike most other URL schemes, does not designate a resource that is universally accessible over the Internet.

TL;DR

You can’t force open to open a target as a file when the argument can be one of many things. In this case, a file with a colon could be either URL or it could be a file; thus the prompt you are seeing.

This is due to the “permissible characters” (byte arrays, actually) that make up a filename on Unix as well as the confusion created behind what a URL is defined as.

As for a “reverse” of open -u, well, that just doesn’t exist as an argument for the open command.

Source Link
Allan
  • 104.4k
  • 33
  • 206
  • 470

I'm guessing that open thinks that the filename might be a URL.

You would be correct. Unix/BSD/Linux/etc. (macOS is a certified Unix) don’t use characters for filenames. Instead, it’s an array of bytes. With the exception of a few characters like the Null character (0x00) and forward slash (0x2f - /) pretty much everything else is fair game including colons.

Is there some way to force open to open the file by default if the file exists,

Unfortunately, no. Your operating system (macOS in this case) cannot tell the difference between a filename with a colon or a URL with a colon.

Why?

The problem here is that per the URL Specification (RFC-1738), §2.1, The main parts of URLs define what a URL is supposed to look like…

A URL contains the name of the scheme being used () followed by a colon and then a string (the ) whose interpretation depends on the scheme.

Emphasis Mine