staging.inyokaproject.org

Zuordnung Mime-Typ Fish-Skripte

Status: Gelöst | Ubuntu-Version: Ubuntu Budgie 24.04 (Noble Numbat)
Antworten |

Mylin

Avatar von Mylin

Anmeldungsdatum:
23. Juli 2024

Beiträge: 371

Hallo zusammen,

ich suche den Fehler bei der Zuordnung des Mime-Typ für Fish-Skripte wenn sie keine Dateinamenerweiterung haben.

x-fishscript.xml um <magic> ergänzt

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?xml version="1.0" encoding="utf-8"?>
<mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="application/x-fishscript">
  <!--Created automatically by update-mime-database. DO NOT EDIT!-->
  <comment>Fish shell script</comment>
  <comment xml:lang="uk">скрипт оболонки fish</comment>
  <comment xml:lang="sv">Fish-skalskript</comment>
  <comment xml:lang="ru">Сценарий fish shell</comment>
  <comment xml:lang="pl">Skrypt powłoki Fish</comment>
  <comment xml:lang="it">Script shell Fish</comment>
  <comment xml:lang="eu">Fish shell scripta</comment>
  <comment xml:lang="es">secuencia de órdenes de consola Fish</comment>
  <comment xml:lang="de">Fish-Shell-Skript</comment>
  <comment xml:lang="be">скрыпт Fish shell</comment>
  <sub-class-of type="application/x-executable"/>
  <sub-class-of type="text/plain"/>
  <alias type="text/x-fish"/>
  <generic-icon name="text-x-script"/>
  <glob pattern="*.fish"/>
  <magic priority="50">
    <match value="#!/bin/fish" type="string" offset="0"/>
    <match value="#!/usr/bin/fish" type="string" offset="0"/>
  </magic>
</mime-type>

... ausgeführt

1
sudo xdg-mime install --mode system ./x-fishscript.xml

Mime-Typ der Fish-Skripte ohne Dateinamenerweiterung bleibt bei text/x-devicetree-source. Was ist mein Fehler?

shiro Team-Icon

Supporter

Anmeldungsdatum:
20. Juli 2020

Beiträge: 1303

Hallo Mylin,

so ganz falsch sieht die Definition für mich nicht aus. Es fehlt aus meiner Sicht nur die <mime-info> Klammer und die korrekte <mime-type> Definition. Ich habe mal als Beispiel deine Definition im folgenden bash Script eingetragen (fish.xml), eine Testdatei erzeugt mit Filetype (test.fish) und ohne (xxx).

Deine Mime-Installation habe ich mit "--novendor" ausgeführt und dann die üblichen "query" und "file" Abfragen auf die Testdateien losgelassen. Am Ende habe ich die Definition wieder mit "uninstall" zurück gesetzt.

Probier es mal aus und teile mit, wo du Probleme siehst.

#/bin/bash
cat >fish.xml <<**eof**
<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
 <mime-type type="application/x-fishscript">
  <comment>Fish shell script</comment>
  <comment xml:lang="uk">скрипт оболонки fish</comment>
  <comment xml:lang="sv">Fish-skalskript</comment>
  <comment xml:lang="ru">Сценарий fish shell</comment>
  <comment xml:lang="pl">Skrypt powłoki Fish</comment>
  <comment xml:lang="it">Script shell Fish</comment>
  <comment xml:lang="eu">Fish shell scripta</comment>
  <comment xml:lang="es">secuencia de órdenes de consola Fish</comment>
  <comment xml:lang="de">Fish-Shell-Skript</comment>
  <comment xml:lang="be">скрыпт Fish shell</comment>
  <sub-class-of type="application/x-executable"/>
  <sub-class-of type="text/plain"/>
  <alias type="text/x-fish"/>
  <generic-icon name="text-x-script"/>
  <glob pattern="*.fish"/>
  <magic priority="50">
    <match value="#!/bin/fish" type="string" offset="0"/>
    <match value="#!/usr/bin/fish" type="string" offset="0"/>
  </magic>
 </mime-type>
</mime-info>
**eof**
#
cat >test.fish <<**eof**
#!/bin/fish
# Diese Datei sollte als fish script erkannt werden
**eof**
#
cp test.fish xxx
#
sudo xdg-mime install --novendor --mode system fish.xml
#
xdg-mime query filetype test.fish
#->application/x-fishscript
#
xdg-mime query filetype xxx
#->application/x-fishscript
#
file xxx
#->xxx: a /bin/fish script, ASCII text executable
#
file test.fish
#->test.fish: a /bin/fish script, ASCII text executable
#
sudo xdg-mime uninstall --novendor --mode system fish.xml
#
xdg-mime query filetype xxx
#->text/plain
#

Mylin

(Themenstarter)
Avatar von Mylin

Anmeldungsdatum:
23. Juli 2024

Beiträge: 371

Hallo shiro,

besten Dank, es lag an der fehlenden <mime-info> und der nicht korrekten <mime-type>. Allerdings, die Einträge innerhalb <mime-type> werden gedoppelt, ich habe auf den <magic> Block gekürzt, das ist ja eigentlich auch das was benötigt wird, und damit ist alles schick.

1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
 <mime-type type="application/x-fishscript">
  <magic priority="50">
    <match value="#!/bin/fish" type="string" offset="0"/>
    <match value="#!/usr/bin/fish" type="string" offset="0"/>
  </magic>
 </mime-type>
</mime-info>

bash und fish Skripte sind damit optisch einwandfrei zu unterschieden. 👍

Bearbeitet von rklm:

Syntaxhighlighting

Antworten |