Shell Script MIME Type
text/x-shellscript means, how .sh files are identified, which shells can run them, and how Poly supports them. MIME type details for text/x-shellscript
In active use| MIME type | text/x-shellscript |
|---|---|
| Extensions | .sh |
| First standardized | Unknown (unregistered) |
| Created by | Unknown |
| Browser support | Chrome, Edge, Firefox, Opera, Safari |
| Example applications | GNU Bash, Visual Studio Code |
| Poly support | Yes. Poly recognizes `.sh` shell scripts and keeps their readable source available without running it. |
| Indexed by Poly | Yes. Poly indexes the script's filename and readable text for exact and semantic search. |
| Preview in Poly | Yes. Shell scripts open in Poly's code-friendly text viewer with language-aware highlighting. |
| Poly agent | Yes. The Poly agent can read and reason about the script's text, but it does not execute the script. |
What does text/x-shellscript mean?
The text/x-shellscript media type labels a text payload as a shell script. Such a file contains commands for a command-line shell, commonly the POSIX sh language or a shell-specific dialect such as Bash, Zsh, or KornShell. POSIX defines a shell script simply as a file containing shell commands.1
The usual filename extension is .sh, but the extension is a convention rather than part of the language. Executable scripts on Unix-like systems often have no extension at all. A script can also be passed directly to an interpreter, as in bash setup.sh or sh task.sh.
text/x-shellscript describes textual source. It does not identify one precise shell dialect, prove that the script is valid, or grant permission to execute it.Is text/x-shellscript an official MIME type?
No. text/x-shellscript is not registered in IANA's media type registry, so it has no official registration template, standardized extension list, named inventor, or registration date.2 The x- prefix survives from older conventions for nonstandard names. Current media type guidance no longer treats an x- prefix as a registration tree and recommends registration for generally useful, widely deployed types.3
The label is still used in real systems. Cloud-init recognizes text/x-shellscript for user-data scripts, and AWS documents it for shell-script parts in MIME multipart user data.4
Linux desktop MIME databases commonly use a different nonstandard name, application/x-shellscript. The freedesktop shared MIME database associates that name with *.sh, treats it as plain text and executable content, and detects several interpreter paths after #!.5 It does not list text/x-shellscript as an alias, so software can disagree about which label to emit.
| Context | Common label | Practical meaning |
|---|---|---|
| Cloud-init MIME user data | text/x-shellscript | A shell-script part that cloud-init may run |
| Linux shared MIME database | application/x-shellscript | A shell script identified by name or interpreter line |
| Generic web delivery | text/plain; charset=utf-8 | Text meant to be displayed rather than dispatched as a specialized script |
If two systems must exchange these files, agree on the media type instead of assuming every MIME database uses the same spelling.
How do you identify a shell script?
Shell scripts do not have one fixed binary signature. They are text files, and the first line often names an interpreter with a shebang, for example:
#!/usr/bin/env bash
set -euo pipefail
printf '%s\n' "Hello"
GNU Bash documents that #! at the beginning of the first line can tell the operating system which interpreter to use. It also notes that interpreter-line details vary between systems.6 This makes #! useful evidence, but not a universal magic number:
- A script can omit the shebang and still run when passed to
shorbash. #!/bin/shand#!/usr/bin/env bashcan select languages with different features.- A
.shfilename can contain ordinary text or even unrelated data. - A valid shell script can have no extension.
For those reasons, this page does not claim a magic number. Check the filename, inspect the first line, and parse the file with the intended shell when accuracy matters.
How to open and check a .sh file
Any plain-text or source-code editor can open an .sh file. Visual Studio Code and similar editors can highlight shell syntax. Bash can read and execute a file supplied as its script argument.6
Before running an unfamiliar script:
- Open it as text and inspect every command.
- Confirm the interpreter named by the shebang is installed and appropriate.
- Use the intended shell's syntax-check mode, such as
bash -n script.sh, when applicable. - Review variables, quoting, redirects, downloads, privilege changes, and destructive commands.
- Run it only with the permissions and isolation you are prepared to grant.
Browsers can generally display textual responses, but web behavior depends on the server's Content-Type and Content-Disposition headers. Browsers use the MIME type, not just the extension, to decide how to handle a resource.7 Serving a script as text does not make the browser execute shell commands.
Support in Poly
Poly recognizes .sh files as text/x-shellscript. You can:
- Open the script in a code-friendly text viewer with language-aware highlighting.
- Search its filename and readable contents using exact or semantic queries.
- Ask the Poly agent to read, explain, summarize, or reason about the source.
Poly does not execute the script while previewing, indexing, searching, or making it available to the agent. This keeps the experience focused on inspection and understanding. It also means Poly does not test whether commands succeed on a particular operating system, shell version, account, or environment.
Portability between sh, Bash, and other shells
The media type cannot tell you which shell language a file uses. The interpreter line and the script's syntax carry that information.
| Script characteristic | Likely expectation | Portability consequence |
|---|---|---|
#!/bin/sh | POSIX-style shell language | Avoid Bash-only syntax if the system's sh is another shell |
#!/usr/bin/env bash | Bash found through PATH | Bash features are reasonable, but the resolved version can vary |
#!/bin/zsh | Zsh at a fixed path | The path and Zsh must exist on the target system |
| No shebang | Caller chooses the interpreter | Running sh file and bash file can produce different results |
POSIX specifies the sh command language, while Bash documents behavior that changes when it is invoked as sh or placed in POSIX mode.8 A .sh extension alone therefore does not promise POSIX compatibility.
Converting a shell script
A shell script is already text, so most "conversion" tasks are really transformations:
- Save it as UTF-8 text when tools need a consistent encoding.
- Normalize line endings for the target operating system.
- Change the shebang only when the new interpreter can parse the script.
- Rewrite nonportable commands or shell-specific syntax when moving between shells.
- Use
text/plainfor generic display when the receiver has no agreed meaning fortext/x-shellscript.
Renaming script.sh to script.txt changes how some applications classify it, but it does not remove commands or make unsafe content safe. Likewise, changing only the MIME label does not translate Bash syntax into POSIX sh.
text/x-shellscript in cloud-init
In cloud-init, this media type can be operational rather than merely descriptive. A user-data script beginning with #! is run once per instance during cloud-init's final stage.9 AWS also uses text/x-shellscript to distinguish shell-script blocks inside multipart user data.4
That context is important. A mail attachment or web response labeled text/x-shellscript should not automatically execute, while a cloud provisioning system may intentionally interpret the same label as instructions. Always evaluate the label together with the receiving application's documented behavior.
Footnotes
- The Open Group. POSIX.1-2024 Definitions: Shell Script. ↩
- Internet Assigned Numbers Authority. Media Types Registry. The text registry does not include
x-shellscript. ↩ - Internet Engineering Task Force. RFC 6838, Media Type Specifications and Registration Procedures. ↩
- Amazon Web Services. Working with Amazon EC2 User Data for AWS PCS. ↩ ↩2
- freedesktop.org shared-mime-info project, mirrored by Debian.
application/x-shellscriptMIME Database Definition. ↩ - GNU Project. Bash Reference Manual: Shell Scripts. ↩ ↩2
- MDN Web Docs. Media Types (MIME Types). ↩
- GNU Project. Bash POSIX Mode. ↩
- Canonical. cloud-init User-data Script. ↩